Caching Tomcat Server
Caching helps when you want to leverage files not being downloaded each time and serve it from cache. Browser headers needs to have such information so that cached content get expires it self after sometime.
Below are steps to implement Caching on Tomcat server
1. You will have to download “Cache Filter” jar file from the below location.
http://code.google.com/p/cache-filter/downloads/list
2. Put that jar file in tomcat/webapps/ROOT/WEB-INF/lib location.
3. Edit tomcat/webapps/ROOT/WEB-INF/web.xml file and add filter and filter-mapping properties as mentioned below.
imagesCache
com.samaxes.filter.CacheFilter
static true
expirationTime 2592000
cssCache
com.samaxes.filter.CacheFilter
expirationTime 604800
jsCache
com.samaxes.filter.CacheFilter
private true
expirationTime 216000
cssCache
*.css
jsCache
*.js
4. Restart Tomcat and check the expires headers on browsers.
Anblicks is a Data and AI company, specializing in data modernization and transformation, that helps organizations across industries make decisions better, faster, and at scale.