Tuning cache
When we are running multiple applications on Tomcat 7, it is always recommended to utilize the resource correctly. In order to do so, we need to optimize the tuning parameter. Every time the server receives a request, it consumes the amount of CPU and memory in the system. In order to resolve this problem, we generate cache on the server from the first request. One of the best examples used for caching in major web hosting organizations is to generate cache for the static content.
The following code shows the configuration for adding Expires
and Cache-Control: max-age=
headers to images, CSS, and JavaScript. This code is added in web.xml
, which is present in TOMCAT_HOME/CONF.
<filter> <filter-name>ExpiresFilter</filter-name> <filter-class>org.apache.catalina.filters.ExpiresFilter</filter-class> <init-param> <param-name>ExpiresByType image</param-name> <param-value>access plus 15 minutes</param-value> </init-param...