一般缓存配置示例
# 静态文件
location ~ ^/web/.*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
expires 20d;
access_log off;
}
location ~ ^/web/.*\.(js|css)?$ {
expires 7d;
access_log off;
}
配置协商缓存示例
解决了静态资源修改后不更新的问题
# 公共静态页面
location / {
add_header Cache-Control no-cache; # 加上这个响应头,表示协商缓存,解决了静态资源修改后不更新的问题
index index.html index.htm;
}