更新index.html后页面存在缓存

Linux 发表时间:2020-12-10 14:47:01 作者:梁子亮 浏览次数:1225

nginx配置index.html不缓存的办法

location /index.html {
    #return 404 "not found";
    #add_header Cache-Control no-cache
    add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
}

或者把js|css|html页面的过期时间改为1h, 2m, 3s,5d,-1 注:-1表示永远过期(未测试),1h表示1小时,2m表示2分钟,3s表示3秒,5d表示5日

location ~ .*\.(js|css|html)?$
{
    expires      1h;
}