我正在尝试让我的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"
}
}如果我检查浏览器控制台,规则似乎工作正常:

但是,它仍然在加载过时的文件,我需要硬重新加载才能看到更改。你知道问题出在哪里吗?
发布于 2018-04-16 06:45:08
好了,我想通了。我在运行ng build时没有使用-prod标志,所以js和css包的名称中没有添加散列(即main.bf49565a4e90c0772548.bundle.js),所以这些文件仍然会被缓存。
https://stackoverflow.com/questions/49847412
复制相似问题