I got an Apache Tomcat 7 server. If I change a file on the server (for example stylesheet, javascript file or any plain/text file), for example using vim. Then if I go to the file in an internet browser, and press F5 a few times till I see the actual change, I have to wait (while pressing F5 every 500 ms) a few seconds (~3 seconds) before I see what I just changed.
Thus in short: if a file is changed on the server, I see it ~3 seconds later client side. So somewhere there has to be a cache, probably server side since I use F5 which should discard client side cache. So how can I setup a directory on my Apache Tomcat server so that it will not cache files?
I want to do this because I created a simple Ajax/Servlet based website to chat. But after typing a message, it will appear ~3 secs later. I know this can be way faster, because I have done it before on a PHP free webhost server.
Tomcat caches static content with a TTL of 5 secs by default. If you want to change that see http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Attributes. Specifically you want cacheTTL, cachingAllowed and maybe cacheMaxSize and cacheObjectMaxSize.
Not sure how Tomcat adds the no cache to everything. The easy way to control the headers yourself is to write and configure a generic header filter in web.xml as follows:
=== web.xml ===
NoCache x.y.z.filters.ResponseHeaderFilter
Cache-Control no-cache, must-revalidate
CacheForWeek uk.co.slc.crm.common.filters.ResponseHeaderFilter
Cache-Control max-age=604800, public
NoCache /*.do
CacheForWeek /images/*
CacheForWeek /*.js
CacheForWeek /*.css
=== web.xml ===