This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat & javascript browser caching" Watch "Tomcat & javascript browser caching" New topic
Author

Tomcat & javascript browser caching

Konstantin Netkachev
Greenhorn

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: 16158
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
Don't get me started about those stupid light bulbs.
 
subject: Tomcat & javascript browser caching