[英]automatic javascript versioning to avoid browser cache clean
My web application uses a bunch of javascript files and I want to version them as and when different releases of my app are out. 我的Web应用程序使用了一堆JavaScript文件,我想在不同版本的应用程序发布时对其进行版本控制。 This is so that the users do not have to clean the cache everytime I publish a new js with my release. 这样一来,用户每次发布新的js时都不必清理缓存。
Example for version 0.0.5
for my app I want all my js to be inside app/js/0.0.5/common/
etc 我的应用程序version 0.0.5
示例我希望我的所有js都在app/js/0.0.5/common/
等内部
I am using maven. 我正在使用Maven。 But have no clue how to automate this kind of versioning. 但是不知道如何自动化这种版本控制。 I know one thing for sure, will need a replace plugin to replace all tokens in my jsps to the right version number at build time. 我肯定知道一件事,将需要一个替换插件来在构建时将我的jsps中的所有令牌替换为正确的版本号。
You can force browser not to cache files that may update in future like this: 您可以强制浏览器不要缓存将来可能更新的文件,如下所示:
<script src="/app/js/0.0.5/common?nc=<generate unique string here>"></script>
so src will be different every time so browser will not cache this script 因此src每次都会不同,因此浏览器不会缓存此脚本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.