Reputation: 835
How do I disable Tomcat caching for a particular static file at location
[Tomcat Path]/webapps/myapp/foo.html
Thank you
Upvotes: 0
Views: 2179
Reputation: 48087
You can't configure it on a single file level. Tomcat's configuration granularity doesn't allow for this IMHO. (judging from your reply to Daniel Scott's comment you're aiming for a single file)
Your question implies that you're not following best practices anyway: It seems that this static file arbitrarily (e.g. through uploads etc) changes and you need to download it again. This implies that you're changing files in your deployed webapp - which is definitely against best practices.
You should rather upload the file to some other location and provide your own download servlet to serve those external resources. In that servlet, you are able to implement the caching headers yourself and basically meet all your needs. Keep in mind that a webapplication could also be served from a fully zipped WAR file - and you couldn't update that WAR file by just changing arbitrary files. Lastly, from a security standpoint, I feel that it's also bad practice to have the webapps directory writeable at all times.
So: Stop looking for tomcat configuration, rather implement your own custom download and caching headers. Change your URLs to refer to your download servlet location. This results in the desired behaviour of your application, although it technically doesn't answer your question the way you probably wanted it to be answered.
Upvotes: 2