The Blog

Liferay front-end performance tuning

published February 1, 2010

As we are getting over 200 000 unique visitors on a busy day, we really must take a full advantage of the Liferay caching. In order to understand caching in Liferay 5.2.3, I had to dig pretty deep. There are multiple ways to increase the portal performance but the focus here will be the Liferay front-end.

The Liferay front-end caching is based on servlet filters and it basically provides four ways to enhance performance:

  • HTTP header based caching
  • Ehcache based caching
  • HTTP response Minifier
  • HTTP response gzipping

liferay-filters

HTTP Header based caching

Liferay provides “com.liferay.portal.servlet.filters.header.HeaderFilter”, which can be used to manipulate HTTP cache-control. This your first line of defence.

Ehcache based caching

This one is the most tricky one. By default, Liferay provides “com.liferay.portal.servlet.filters.cache.CacheFilter” for caching requests in the Ehcache. Unfortunately, Ehcache configurations are buried deep. If you have Liferay source code, you should take a peek of files under “/portal/portal-impl/src/ehcache/”, especially files with a “liferay” prefix. Usage of these configuration files are configured in a portal.properties file using keys “ehcache.single.vm.config.location” and “ehcache.multi.vm.config.location”.

Underneath, The CacheFilter uses named cache “com.liferay.portal.servlet.filters.cache.CacheUtil” to store responses, which has time to live set to a one hour. The CacheFilter constructs cache keys like “HTTP:///WEB/FI/FRONTPAGE?NULL#FI_FI#OTHER#TRUE” from the request and stores rendered bytes into the Ehcache for later use.

It is configured to include specific resources in web.xml. If you need custom caching for your pages, you can do it with the CacheFilter.

HTTP response gzipping

By gzipping the response, round trip response time will be shorter. See a sample on SteveShoulds.com. Gzipping is done using class “com.liferay.portal.servlet.filters.gzip.GZipFilter”.

HTTP response Minifier

Liferay provides “com.liferay.portal.servlet.filters.minifier.MinifierFilter” which can be used to minify responses. It uses Yahoo’s YUI Compressor to compress e.g. css and javascript files.

Configurations

All filters are defined in web.xml and are already pre-configured. In order to change configurations you will need Liferay source code. It is easier to understand configurations by looking at the code.

Samuli @ 21:48 (2 Comments)

tags: ,

Trackback URL

Subscribe to RSS feed

The Tag Cloud
The Blog Archive

February 2012 (1)

January 2012 (1)

November 2011 (1)

June 2011 (2)

May 2011 (1)

April 2011 (2)

March 2011 (2)

February 2011 (1)

January 2011 (1)

December 2010 (1)

November 2010 (1)

October 2010 (3)

September 2010 (3)

August 2010 (5)

July 2010 (2)

June 2010 (3)

May 2010 (4)

April 2010 (2)

March 2010 (6)

February 2010 (7)

January 2010 (3)

December 2009 (7)

November 2009 (6)