File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Tomcat & javascript browser caching Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat & javascript browser caching" Watch "Tomcat & javascript browser caching" New topic

Tomcat & javascript browser caching

Konstantin Netkachev

Joined: Jul 24, 2009
Posts: 15
Our Java web application works on Tomcat 6. Most of user use FireFox.

We faced a problem. After changing javascript files on server, they allways taken from browser cache on client side and doesn't updated auromaticaly from server. Only CTRL+F5 resolves that but users don't know it and allways swear at errors.

Is there possibility to somehow resolve this problem? May be to change some tomcat configurations?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

You can control client caching by adjusting the cache headers sent back with the response to the JavaScript resource requests, up to and including "no-cache". You can force a change by including a version ID as part of the URL, since caching is based on the URL itself and not on the returned content.

For production systems, cache is generally preferable, since things like JavaScript, CSS, and many images are not usually very changeable. In cases where you are dynamically creating the contents of the returned JavaScript, that's another matter.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Tomcat & javascript browser caching
jQuery in Action, 3rd edition