我试图让我的Angular应用程序的索引页面不要缓存。我根据this post格式化了我的firebase.json规则:
{
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"functions": {
"predeploy": "npm --prefix functions run build"
},
"hosting": {
"public": "dist",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
],
"headers" : [{
"source": "/**",
"headers": [
{
"key": "Cache-Control",
"value": "no-cache, no-store, must-revalidate"
}
]
},
{
"source":
"**/*.@(jpg|jpeg|gif|png|svg|js|css|eot|otf|ttf|ttc|woff|font.css)",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=604800"
}
]
}]
},
"storage": {
"rules": "storage.rules"
}
}
如果我检查浏览器控制台,似乎规则正常:
但是,它仍然在加载过时的文件,我需要重新加载才能看到更改。知道问题是什么吗?
答案 0 :(得分:0)
好的我明白了。我在运行asScala
时没有使用-prod
标志,因此js和css包没有在其名称中添加哈希值(即ng build
),因此这些文件仍在缓存中