Add config for browser cache use
To improve page load performance, some static resources may have some cache control information in their headers.
We can arrange this in the generated web.xml
For now I’ll add the following filters, resulting in any image/css/js to be cached by browsers for at most 7 days after first retrieval.
We only target static content that appear in one of the directoriesstylesheets
,images
orjavascript
, plus the favicon.ico in root.Submitted by Elmer van Chastelet on 24 November 2012 at 18:23<filter> <filter-name>ExpiresFilter</filter-name> <filter-class>fr.xebia.servlet.filter.ExpiresFilter</filter-class> <init-param> <param-name>ExpiresByType image</param-name> <param-value>access plus 7 days</param-value> </init-param> <init-param> <param-name>ExpiresByType text/css</param-name> <param-value>access plus 7 days</param-value> </init-param> <init-param> <param-name>ExpiresByType application/javascript</param-name> <param-value>access plus 7 days</param-value> </init-param> <!-- backwards compatibility --> <init-param> <param-name>ExpiresByType text/javascript</param-name> <param-value>access plus 7 days</param-value> </init-param> </filter> <filter-mapping> <filter-name>ExpiresFilter</filter-name> <url-pattern>/stylesheets/*</url-pattern> <dispatcher>REQUEST</dispatcher> </filter-mapping> <filter-mapping> <filter-name>ExpiresFilter</filter-name> <url-pattern>/javascript/*</url-pattern> <dispatcher>REQUEST</dispatcher> </filter-mapping> <filter-mapping> <filter-name>ExpiresFilter</filter-name> <url-pattern>/images/*</url-pattern> <dispatcher>REQUEST</dispatcher> </filter-mapping> <filter-mapping> <filter-name>ExpiresFilter</filter-name> <url-pattern>/favicon.ico</url-pattern> <dispatcher>REQUEST</dispatcher> </filter-mapping>
Issue Log
On 26 November 2012 at 10:36 Elmer van Chastelet commented:
Added in rev 5534+5535. Tested on tomcat 6 and 7.
On 26 November 2012 at 10:36 Elmer van Chastelet closed this issue.
Log in to post comments