How do I disable tomcat caching? I'm having weird static file problems
Solution 1:
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"
cachingAllowed="false"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true"
reloadable="false"
wrapperClass="org.apache.catalina.core.StandardWrapper">
</Context>
Solution 2:
For Tomcat 8 / Tomcat 9 properties should be added in conf/context.xml as follows
<Context>
<Resources antiResourceLocking="false" cachingAllowed="false" />
...
</Context>
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\
See Apache Tomcat 9 Configuration Reference for other parameters.
Solution 3:
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"
Solution 4:
Have you checked this documentation: Apache Tomcat Configuration Reference ?
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.
These parameters are the same for Tomcat 5.5 and Tomcat 6.0.