<p>下面是本站的Nginx反向代理缓存Proxy Cache配置文件范例,仅供各位站长参考,源站点在美国,用日本的vps做Nginx代理缓存测试,实际测试效果不错. 要注意proxy_temp_path和proxy_cache_path目录本身和上级目录都要有相应权限,不然就会有生成缓存文件失败的权限错误提示. 如果需要重新生成缓存,直接把缓存目录里面的子目录都删除就可以了.</p><p>proxy_temp_path /home/ctohome/proxy_temp_dir 1 2;<br />proxy_cache_path /home/ctohome/proxy_cache_dir levels=1:2 keys_zone=ctohome:50m inactive=1d max_size=30g;</p><p>server {<br /> listen 210.175.52.111:80;<br /> server_name www.ctohome.com .ctohome.com;<br /><br /> location / {<br /> proxy_pass http://ctohome.com/;<br /> proxy_redirect off;<br /> proxy_set_header X-Real-IP $remote_addr;<br /> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br /> proxy_set_header Host $host;<br /><br /> proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404;<br /><br /> client_max_body_size 10m;<br /> client_body_buffer_size 128k;<br /><br /> proxy_connect_timeout 90;<br /> proxy_send_timeout 90;<br /> proxy_read_timeout 90;<br /><br /> proxy_cache ctohome; <br /> proxy_cache_valid 200 302 12h; <br /> proxy_cache_valid 301 1d; <br /> proxy_cache_valid any 1h; <br /><br /> proxy_buffer_size 4k;<br /> proxy_buffers 4 32k;<br /> proxy_busy_buffers_size 64k;<br /> proxy_temp_file_write_size 64k;<br /> }<br />}</p><br />