only html file no-cache

codetr nginx-forum at nginx.us
Wed Dec 28 18:50:02 UTC 2011


hi; my use reverse proxy and html files to be read by nginx, but I just
want to have onyl html files no-cache ..

my v_hosts.conf
server {
          error_log /var/log/nginx/vhost-error_log warn;
          listen 46.4.103.194:80;
          server_name skystar-2.com dvbking.com www.dvbking.com
www.skystar-2.com;
          access_log /usr/local/apache/domlogs/skystar-2.com-bytes_log
bytes_log;
          access_log /usr/local/apache/domlogs/skystar-2.com combined;
          root /home/skystar2/public_html;
          error_page  404              /404.shtml;
          error_page  403              /403.shtml;
          error_page   502 503 504  /50x.html;
          location / {
          location
~.*\.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|txt|js|css|html|htm|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$
{
          expires 7d;
          try_files $uri @backend;
          }
          error_page 405 = @backend;
          add_header X-Cache "HIT from Backend";
          proxy_pass http://46.4.103.194:8081;
          include proxy.inc;
          }
          location @backend {
          internal;
          proxy_pass http://46.4.103.194:8081;
          include proxy.inc;
          }
          location ~ .*\.(php|jsp|cgi|pl|py)?$ {
          proxy_pass http://46.4.103.194:8081;
          include proxy.inc;
          }
          location ~ /\.ht {
          deny all;
          }
        }

my nginx.conf

user  nobody;
# no need for more workers in the proxy mode
worker_processes  2;
error_log  /var/log/nginx/error.log info;
worker_rlimit_nofile 20480;
events {
 worker_connections 5120; # increase for busier servers
 use epoll; # you should use epoll here for Linux kernels 2.6.x
}
http {
 server_name_in_redirect off;
 server_names_hash_max_size 10240;
 server_names_hash_bucket_size 1024;
 include    mime.types;
 default_type  application/octet-stream;
 server_tokens off;
 sendfile on;
 tcp_nopush on;
 tcp_nodelay on;
 keepalive_timeout  5;
 gzip on;
 gzip_vary on;
 gzip_disable "MSIE [1-6]\.";
 gzip_proxied any;
 gzip_http_version 1.1;
 gzip_min_length  1000;
 gzip_comp_level  2;
 gzip_buffers  16 8k;
# You can remove image/png image/x-icon image/gif image/jpeg if you have
slowCPU
 gzip_types text/plain text/html text/htm text/xml text/css
application/x-javascript application/xml application/xml+rss
text/javascript application/atom+xml;
 ignore_invalid_headers on;
 client_header_timeout  3m;
 client_body_timeout 3m;
 send_timeout     3m;
 reset_timedout_connection on;
 connection_pool_size  256;
 client_header_buffer_size 256k;
 large_client_header_buffers 4 256k;
 client_max_body_size 200M; 
 client_body_buffer_size 128k;
 request_pool_size  32k;
 output_buffers   4 32k;
 postpone_output  1460;
 proxy_temp_path  /tmp/nginx_proxy/;
 client_body_in_file_only on;
 log_format bytes_log "$msec $bytes_sent .";
 include "/etc/nginx/vhosts/*";
}

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,220621,220621#msg-220621



More information about the nginx mailing list