Firebase托管:部署时缓存清除脚本 [英] Firebase Hosting: cache busting scripts on deploy
问题描述
我在firebase上托管了Polymer(单页应用)应用程序.当我将新版本部署到Firebase时,我希望Firebase重新加载javascript源而不是使用缓存的源.是否有可能通过firebase.json做到这一点?如果是这样,怎么办?还是我必须手动将缓存清除网址添加到我的生成输出中?谢谢
I have a Polymer (single page app) application hosted on firebase. When I deploy a new version to firebase, I'll like firebase to reload the javascript source instead of using cached ones. Is it possible to do that via firebase.json? If so, how? Or do i have to manually add a cache busting url to my build output? Thanks
推荐答案
向您的版本中添加Webpack或类似工具可能是最简单的方法,因为目前尚无一种方法可以直接使用Firebase直接达到所需的结果:
Adding Webpack or a similar tool to your build is probably the easiest way to go, as there's not currently a way to achieve the desired result with Firebase directly:
如果可以完全删除缓存,则可以为不想缓存在firebase.json
中的文件设置相关标头:
If you're okay removing the cache completely, you can simply set the related headers for the files you don't want cached in firebase.json
:
{
...
"headers": [{
"source": "build.js",
"headers": [{
"key": "Cache-Control",
"value": "max-age=0"
}]
}],
...
}
有关更多详细信息,请参见此处: https://firebase.google.com /docs/hosting/full-config#headers
See here for more details: https://firebase.google.com/docs/hosting/full-config#headers
这篇关于Firebase托管:部署时缓存清除脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!