server {
listen 8098;
server_name localhost;
location /testPro{
root html;
proxy_pass http://127.0.0.1:5980/testPro;
#js css 文件不緩存
if ($request_filename ~* ^.*?.(js|css)$){
add_header Cache-Control max-age=0;
}
}
}
max-age>0 時 用戶訪問時直接讀取靜態資源緩存,緩存保留時間為max-age的值;(靜態資源保留超過max-age的值:200;保留時間段內:304)
max-age<=0 若靜態資源的Last-Modified 發生改變,則項服務器獲取靜態文件,否則依然讀取瀏覽器緩存;(靜態資源更新:200;不變:304)
no-cache 若靜態資源的Last-Modified 發生改變,則項服務器獲取靜態文件,否則依然讀取瀏覽器緩存; (靜態資源更新:200;不變:304)
no-store 瀏覽器不緩存,直接獲取服務器靜態資源;(200)