Caching static content

Caching for static resources can be enabled for improved performance. The browser would cache the resources served for the specified time period. The cache-period attribute or the setCachePeriod method can be used to specify the caching interval (in seconds) based on the type of configuration used. The following snippets show the details.

This is the Java configuration:

    registry 
.addResourceHandler("/resources/**")
.addResourceLocations("/static-resources/")
.setCachePeriod(365 * 24 * 60 * 60);

This is the XML configuration:

    <mvc:resources  
mapping="/resources/**"
location="/static-resources/"
cache-period="365 * 24 * 60 * 60"/>

The Cache-Control: max-age={specified-max-age} response header will be sent to the browser.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset