vue项目index.html缓存

https://www.cnblogs.com/xyyt/p/10431173.html

http://kouss.com/vue-no-cache.html

解决Vue入口文件index.html缓存问题
2018年11月16日 爱搞机  7533次浏览
之前每次更新tool.chaozhi.hk的时候,总是要刷新两次才能生效,现在总算解决这个问题了。

找过很多META标签的设置,例如下面这些,都不管用。

vue-cli里的默认配置,css和js的名字都加了哈希值,所以新版本css、js和就旧版本的名字是不同的,不会有缓存问题。

<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache" content="no-cache">
但是把打包好的index.html放到服务器里去的时候,index.html在服务器端可能是有缓存的,这需要在服务器配置不让缓存index.html
nginx 配置如下:

location = /index.html {
    add_header Cache-Control "no-cache, no-store";
}

 

posted @ 2020-06-08 10:56  ThisCall  阅读(3976)  评论(0编辑  收藏  举报