JS Cache Control
Join the DZone community and get the full member experience.Join For Free
The following JSP snippet shows a simple caching policy for JS files, i.e. the browser fetches js files when a new build is available. qBuildNum is a build number or a repository revision suffix, e.g.?102 etc. ServerInfoService.getBuildNumber() is a function which returns current build number. This function has to be coded manually, alternatively a servlet context attribute can be used...
<% String qBuildNum = '?' + ServerInfoService.getBuildNumber(); //Suffix for JS to avoid caching %>
Opinions expressed by DZone contributors are their own.