admin管理员组文章数量:1399251
I am creating a website using Flutter Web. The website is in production and we release one version a week. Some users have trouble getting the new version of the web application. I would like to set my website to not cache data.
I added these tags, but to no succes:
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
I am creating a website using Flutter Web. The website is in production and we release one version a week. Some users have trouble getting the new version of the web application. I would like to set my website to not cache data.
I added these tags, but to no succes:
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
Share
Improve this question
edited Jul 30, 2021 at 15:02
Filipe Piletti Plucenio
asked Jan 14, 2021 at 22:23
Filipe Piletti PlucenioFilipe Piletti Plucenio
73910 silver badges26 bronze badges
1
- Are you using a CDN or edge provider? Generally you should favor setting the HTTP response header for Caching instead of the meta tags. – Deadron Commented Jan 18, 2021 at 14:55
1 Answer
Reset to default 8 +50It's a decision for your team, but you wouldn't be fine working with versioned URLS
? That is the easiest trick I know for cache invalidation.
In the index.html
file you can pass a unique VERSION_CODE to your main javascript bundle file
before requesting it like
<script src="main.dart.js?VERSION_CODE=7672" type="application/javascript"></script>
And then everytime before doing a flutter build web
you need to update the VERSION_CODE of your index.html file, thus invalidating the client side when they request your bundle. You can automate this, but there's no way to pass environment variables to flutter build web
step.
本文标签: javascriptHow to configure a website using Flutter Web to not cache dataStack Overflow
版权声明:本文标题:javascript - How to configure a website using Flutter Web to not cache data? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744120835a2591731.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论