简体   繁体   中英

Refreshing static javascript files on deployment

Is there an easy way to refresh static JavaScript files on deployment? Everytime we have a deployment which includes changes to static java script files, users start having issues till they clean temporary files in the browser.

A common technique is to append a build number after every JavaScript file.

<script src="file.js?{buildId}"> </script>

The drawback is that the user will have to refetch all files, even if they haven't changed.

Another technique, used by the grails asset pipeline plugin, is to add a hash of the file contents, which is even better because it means if a file hasn't changed you can use the cached version.

<!-- These script tags were generated by the grails assets plugin -->
<script src="/compose/assets/go-debug-0fcab1bdda470dee9578852f88c5ab07.js" type="text/javascript" ></script>
<script src="/compose/assets/Q/q-eb089b6fca3b35ceb26300bcf198b49d.js" type="text/javascript" ></script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM