location /xxxx{
gzip on;
gzip_min_length 1k;
#gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 4;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/gif;
gzip_vary off;
gzip_disable "MSIE [1-6]\.";
alias /html/xxxx/;
index index.html;
if ($request_filename ~* .*\.(?:htm|html)$) ## 配置页面不缓存
{
add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
}
}
配置HTML文件不缓存后,每次更新项目,会重新请求页面,而因为现在的前程工程也都需要打包,在打包工具会自动在文件名上加时间戳、哈希值,这样一发新版时,只要客户端请求了新版的html,里面引用的js/css/jpg等都已经换了路径,肯定也就不会使用本地的缓存了