在nginx配置文件中:
upstream webservers{ server 192.168.1.6 weight=1 max_fails=2 fail_timeout=2; } proxy_cache_path /data/nginx/cache/webserver levels=1:2 keys_zone=webserver:20m max_size=1g; location /{ proxy_pass http://webservers; proxy_set_header X-Real-IP $remote_addr; proxy_cache webserver; proxy_cache_valid 200 10m; }
修改完后重启nginx:sbin/nginx -s reload
通过浏览器访问:192.168.1.6
查看生成缓存文件:
在cd /data/nginx/cache/webserver/
参考链接:http://www.360doc.com/content/13/1114/12/7694408_329125489.shtml
原文地址:http://pilipala.blog.51cto.com/10165737/1650374