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等都已經換了路徑,肯定也就不會使用本地的緩存了