Categories
Java Tomcat

Enable Browser Caching for Tomcat’s Deliveries

Tomcat automatically adds “no-cache” directives to each response. This is not a good idea when you are not using Apache as the serving host for static content. I found a very easy way to get rid of that HTTP header. Just add a new file named “context.xml” to the WEB-INF directory of your application:

1
2
3
4
<context>
	<valve className="org.apache.catalina.authenticator.BasicAuthenticator"  
		disableProxyCaching="false" />
</context>

For finer control, please have a look at Symphonious’ article on that topic.