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

About this user

Fyodor Kupolov http://j2ee.by.ru

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

JS cache control

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
%>
<script type="text/javascript" src="dwr/engine.js?113"></script>
<script type="text/javascript" src="dwr/util.js?113"></script>
<script type="text/javascript" src="rico/prototype.js?14"></script>
<script type="text/javascript" src="rico/rico.js?112"></script>
<script type="text/javascript" src="script/controller.js<%=qBuildNum%>"></script>
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS