服务器:如何设置Nginx缓存策略 |
max将Expires头设置为31 December 2037 23:59:59 GMT,将Cache-Control最大化到10 年。 例如设置php的文件类型过期时间设置为1个小时: 设置php的文件类型为no-cache,不让cache服务器缓存:
另外可以通过add_header设置相对应的缓存策略,对于动态的php文件设置为不缓存:
location ~ .*.php$ {
if ($request_uri !~ ^/dynamicimg/) {
add_header Cache-Control no-cache;
add_header Pragma no-cache;
}
} |