Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


share|improve this question
up vote 11 down vote accepted

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

Configuration can be introduced in server.xml as

<Context className="org.apache.catalina.core.StandardContext"
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
LOL... where's the love? – KPWINC Jul 14 '09 at 21:48
Where do i change the chachingAllowed tag? – kajacx Feb 13 '14 at 12:28
Got a warning from Tomcat 8 when starting: Setting property cachingAllowed to false did not find a matching property. – naXa Sep 28 '15 at 10:49

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 ( ):

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:

share|improve this answer

Have you checked this URL:

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

For Tomcat 8 / Tomcat 9 properties should be added in conf/context.xml as follows

  <Resources antiResourceLocking="false" cachingAllowed="false" />

You might have to delete the application cache folder in /work/Catalina/localhost after changing the cachingAllowed flag. Also clear the cache of IntelliJ IDEA (if you use it to run Tomcat):

Mac:     /Users/{:user}/Library/Caches/IntelliJIdea{:version}/tomcat/  
Linux:   /home/{:user}/.IntelliJIdea{:version}/system/tomcat/
Windows: C:\Users\{:user}\.IntelliJIdea{:version}\system\tomcat\
share|improve this answer
antiResourceLocking on <Resources>-Tag is definitively wrong for tomcat 8 – P.scheit Apr 1 at 12:13

Your Answer


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.