Please consider below sample with struts 2 jquery plugin, ( but this could be happen with jquery)
In struts 2 jquery plugin set head tag to cache ajax calls:
ajaxcache="true"
The html head is ( do not cache any thing):
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Pragma" content="No-cache" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Expires" content="0" />
There is also an interceptor which set resonse header as below:
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control",
"no-cache, no-store, must-revalidate");
response.setDateHeader("Expires", 0);
Consider a sample test.jsp file with single js in it
<script type="text/javascript" src="js/grid.js"></script>
The first time the test.jsp is loaded the grid.js
is loaded and cached by browser, changing the grid.js
will not cause the browser to get updated grid.js
file any more !!
Of course I can fix this issue by setting ajaxcache="false"
My question is, if the grid.js
is loaded only once and the client do not get newly updated js anymore, then what is the use of ajax caching ?!
Can you suggest a real case which you do not need to update any resource on the client, so client can catch a resource for a long time?!
Or we can use ajax caching in other ways ?!