一般浏览器缓存的文件有html、css、js等。
css、js文件被缓存的解决方案
一般html中引入的css和js的名字都加了哈希值,所以新版本css、js和就旧版本的名字是不同的,不会有缓存问题。
如果index.html文件被缓存就稍微麻烦些
首先可以在index.html文件头部添加mate标签禁止缓存
<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
nginx 配置如下:
location = /index.html {
add_header Cache-Control "no-cache, no-store";
统计下指定后缀文件代码总行数
git ls-files | grep -E '\.(ts|js|html|less|css|json)$' | xargs wc -l2023-09-28 13:13
清酒红人面,财帛动人心2023-03-16 10:17
html+css(25)
js+jquery+ajax(55)
js库(17)
angular(13)
前端工具(16)
其他(10)