Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For a complete description of how portlet caching works it is recommended to read section PLT.22 of the JSR-286 specification.

Caching of static assets

uPortal and some portlets are configured to cache static assets such as *.js and *.css configuration in web.xml, a spring context file, and ehcache.xml, for example.  

Code Block
languagexml
titleweb.xml
<filter>
    <filter-name>pageCachingFilter</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    <init-param>
        <param-name>targetFilterLifecycle</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>
    
<filter-mapping>
    <filter-name>pageCachingFilter</filter-name>
    <url-pattern>*.js</url-pattern>
    <url-pattern>*.css</url-pattern>
</filter-mapping>

Other configuration is needed in applicationContext.xml and ehcache.xml, and you typically also use a cacheExpiresFilter  See the following for examples:

Tip

This can be a pain when doing local development because changes to JavaScript or CSS files require restarting Tomcat or other processes.  In these cases one solution to speed development and allow you to see changes to static resources immediately is to temporarily comment out the url pattern from the filter-mapping (but don't check it in).