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.

The blueprint for the AI-native enterprise,
delivered to your inbox.

    Read Next

    Related Insights

    Anblicks’ CloudOps/DevOps Service Experience in Various Industries
    Komal Saini
    8 Dec 2021
    Unlocking the Power of AWS OpenSearch
    Pavitra Kadiyala
    6 Feb 2026
    From Data Debt to AI Value
    Munwar Shariff
    28 May 2026
    ×