Apr 23

nginx 代理缓存的坑 不指定

bkkkd , 23:45 , 开发应用 , 评论(0) , 引用(0) , 阅读(7176) , Via 本站原创 | |
原来网站上一直使用nginx的代理缓存,确实能给服务器节省大量的性能。能将大部分的页面进行缓存,但最近一段时间,发现并没有像以前那样将文件进行缓存。在经过检查后,发现原来 proxy_cache是对头信息有限制的。

http://wiki.nginx.org/HttpProxyModule#proxy_cache

引用
The cache depends on proxy buffers, and will not work if proxy_buffers is set to off.

The following response headers flag a response as uncacheable unless they are ignored:
    Set-Cookie
    Cache-Control containing "no-cache", "no-store", "private", or a "max-age" with a non-numeric or 0 value
    Expires with a time in the past
    X-Accel-Expires: 0


proxy_cache受几个因素影响:
1,proxy_buffers必须启动,否则将不能使用缓存
2,如果头信息存在以下的情况,缓存将会被忽略。
    有Set-Cookie
    Cache-Control的内容包含: "no-cache", "no-store", "private", or a "max-age" 是0
    Expires 设置的时间一个过期的时间
    X-Accel-Expires: 0

经过分析,原来程序中有一个程序修改后,默认所有页面都会传出一个Set-Cookie的值,这个值引起页面一直没有行缓存。从而使用页面服务器一直很慢。
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]