my dog learned polymorphism*
The moose likes Tomcat and the fly likes Does Tomcat cache CSS files? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Does Tomcat cache CSS files?" Watch "Does Tomcat cache CSS files?" New topic
Author

Does Tomcat cache CSS files?

Tim Hagberg
Greenhorn

Joined: Jan 29, 2010
Posts: 12
I have a personal Java-backed website I'm building with Tomcat, and I've run into an annoyance. After making some changes to a stylesheet, when accessing the website from a browser I was getting the old version of the css file. I assumed it was just the browser (Firefox) that was caching the file, but I've tried clearing the browser's cache and it has not helped. If I look at the file on the server or type the url of the css file in my browser, I see the updated version, but when examining it through Firebug I see the old version (and by looking at the rendered page it is obvious that it is using the old version). To rule out Firebug I have tried turning it off and closing/reopening Firefox and loading the page again, but that has not helped. Especially strange is that I tried changing the name of the css file (and obviously also changing link tag on the page as well) but this has not helped. At this point I am wondering if Tomcat's servlet container stores compiled JSPs somewhere, and if that is true perhaps it is storing linked stylesheets as well.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
Tomcat does nothing magic with CSS files, just serves them just like all other static resources.

Surely the caching is occuring somewhere else.

Bill
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

To put it even more bluntly, Tomcat doesn't cache, period.

Is there maybe a caching proxy server between the client and Tomcat?

A trick that I use to get updated cache and CSS in Firefox is to instruct the browser to fetch the updated file directly. That is, I type the updated file's URL directly into the navigation bar so that it displays in a web page all its own. Sometimes I have to give it an extra kick by pressing the Refresh button (F5) once it's loaded to force an update, but that usually works. I can then generally go back and request the page that references the updated resource and expect it to work.


Customer surveys are for companies who didn't pay proper attention to begin with.
Tim Hagberg
Greenhorn

Joined: Jan 29, 2010
Posts: 12
I apologize for the late response. It turns out there was some malformed CSS that apparently Firefox was simply ignoring. I'm no expert on this, but I'm assuming CSS files must be stored somewhere on the DOM, and if that's the case, Firefox wasn't putting the malformed CSS on the DOM. That would explain why I was seeing the new CSS entries when putting in the full URL to the stylesheet in the address bar. Thank you both for your responses and advice.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Does Tomcat cache CSS files?