Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

JS cache control (See related posts)

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...
   1  
   2  <%
   3      String qBuildNum = '?' + ServerInfoService.getBuildNumber(); //Suffix for JS to avoid caching
   4  %>
   5  <script type="text/javascript" src="dwr/engine.js?113"></script>
   6  <script type="text/javascript" src="dwr/util.js?113"></script>
   7  <script type="text/javascript" src="rico/prototype.js?14"></script>
   8  <script type="text/javascript" src="rico/rico.js?112"></script>
   9  <script type="text/javascript" src="script/controller.js<%=qBuildNum%>"></script>

You need to create an account or log in to post comments to this site.


Click here to browse all 5556 code snippets

Related Posts