Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How do I prevent tomcat from caching? I have css and basic html files that I load and use via ajax, and unless I restart tomcat, the changes do not seem to reflect. Different machines, different browsers, and I don't receive the updated files.

Thoughts?

share|improve this question

3 Answers 3

up vote 7 down vote accepted

You might have to delete the application cache folder in /work/Catalina/localhost after changing the cachingAllowed flag.

share|improve this answer
    
+1 I completely forgot to mention that in my original answer. Thanks! –  KPWINC Jul 14 '09 at 1:17
    
Awesome. Works. –  Stefan Kendall Jul 14 '09 at 17:19
1  
LOL... where's the love? –  KPWINC Jul 14 '09 at 21:48
    
Where do i change the chachingAllowed tag? –  kajacx Feb 13 at 12:28

I had this problem in Tomcat 7 and the reason was that I had antiResourceLocking set to true (it sounded like a good idea...).

According to the docs ( http://tomcat.apache.org/tomcat-7.0-doc/config/context.html ):

Please note that setting this to true has some side effects, including the disabling of JSP reloading in a running server: see Bugzilla 37668.

In my case it even caused plain static text files to be cached.

So, in summary, at least for rapid development I had to use:

antiResourceLocking="false"
cachingAllowed="false"
share|improve this answer

Have you checked this URL:

http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

cacheMaxSize -- Maximum size of the static resource cache in kilobytes. If not specified, the default value is 10240 (10 megabytes).

cacheTTL -- Amount of time in milliseconds between cache entries revalidation. If not specified, the default value is 5000 (5 seconds).

cachingAllowed -- If the value of this flag is true, the cache for static resources will be used. If not specified, the default value of the flag is true.

share|improve this answer
    
I set cachingAllowed to false and cacheTTL to 1000 in my appcontext.xml, and I STILL can't get file not to cache. Worse yet, it's caching across tomcat restarts. –  Stefan Kendall Jul 14 '09 at 13:49
    
Then it's gotta be from browser cache –  lisak Apr 7 '11 at 15:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.