简体   繁体   English

自动javascript版本控制以避免浏览器缓存清理

[英]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.

相关问题 使用JavaScript开发时,Web浏览器缓存保持干净 - Web browser cache clean while javascript development 将javascript文件版本化为maven构建的一部分,以避免Web浏览器缓存 - versioning javascript files as part of maven build to avoid web browser caching 如何避免要求客户端清除浏览器缓存以获取最新的Javascript更改? - How to avoid asking the clients to clear browser cache for the latest Javascript changes? 对Javascript文件进行版本控制以防止不必要的缓存清除 - Versioning Javascript Files to Prevent Unnecessary Cache Clearing Tapestry中用于缓存清除的javascript和CSS版本控制 - javascript and CSS versioning for Cache Busting in Tapestry 浏览器缓存-版本文件-但是如果浏览器使用旧版本怎么办? - Browser cache - versioning files - but what if browser uses old version? Javascript版本控制以避免缓存,这些做法有何不同? - Javascript versioning to avoid caching, difference in these practices? 如果浏览器离线,请避免自动刷新浏览器 - Avoid automatic broswer refresh if browser is offline 使用JavaScript更新浏览器缓存 - Update browser cache with javascript Android浏览器缓存和JavaScript - Android browser cache and javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM