We used cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it. What For?

« Back to Blogs

Liferay performance tuning with Apache web server

performance tuning with Apache


Performance tuning streamlines your content and tunes your server to deliver web pages faster. Faster website download speeds have been shown to increase visitor retention and user satisfaction especially for users with slow internet connections. If you have not done optimization from Liferay(portal) side yet, here is our blog Liferay Performance Tuning for it. If you already optimized it then let’s optimize from web server such as Apache. Apache configuration has a major affect on your Liferay’s performance.


Basic things to keep in while developing :

  • Use scaled and optimized images
  • Use minified js and css
  • Optimized web fonts(If you use)
  • To reduce render blocking always add js in bottom of the page and if possible load it asynchronously


Here are the four things to configure from apache web server to give lightning speed to your Liferay portal.


  1. Static content delivery  

  2. GZip compression configuration

  3. Reduce number of requests

  4. Control browser caching


The easiest way to increase server performance is to turn off Apache modules that are not needed.


  1. Static Resources Delivery :


Delivering static resources of the Liferay Portal through the Apache Web Server can improve the response time extremely. When static resources are delivered through the Apache Web Server, no Application Server overhead is added and ultimately, it improves the response time and performance.


You can serve all folders under $tomcat_home ? webapps folder except the root folder from Apache web server.

You can serve following folders from root as well.


$tomcat_home --> webapps --> Root --> Html

$tomcat_home --> webapps --> Root --> layouttpl

$tomcat_home --> webapps --> Root --> wap


It is recommended to serve static resources(css, js, images, etc.) of theme, hook and portlet plugins from Apache web server for better performance.


  1. GZip compression configuration

GZip is a technique to compress http response. It improves response time by reducing the network data transfer. All major browsers support this feature(compressed resources). Liferay by default support this feature using GZip filter. You can turn off Liferay’s GZip compression technique from portal-ext.properties and enable Apache web server GZip compression to enhnace performance. To disable GZip compression from Liferay you need to add following property in portal-ext.properties.




To enable GZip compression from Apache web server you need to enable mod deflate. Add following rules in deflate.conf


<IfModule mod_deflate.c>
         # these are known to be safe with MSIE 6
         AddOutputFilterByType DEFLATE text/html text/plain text/xml

         # everything else may cause problems with MSIE 6
         AddOutputFilterByType DEFLATE text/css
         AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
         AddOutputFilterByType DEFLATE application/rss+xml


Add following line in your .htaccess file


SetOutputFilter DEFLATE


Compression of your HTML and CSS files with gzip typically saves around 50-70% of the file size.


  1. Reduce number of requests


Best practice is to reduce the number of requests. To reduce the number of requests we should combine/merge resources like js, css, etc. Liferay provide built-in feature that combine javascript and css files dynamically. Liferay merges most common javascripts those used by unauthenticated/guest users and serve it as single file barebone.jsp. Likewise, Liferay merges most common javascripts those used by authenticated users and serve it as single file everything.jsp. The process of merging is dynamic and causes waiting time to increase. For a workaround, we can serve barebone.jsp and everything.jsp from Apache web server by following steps.


  • Hit  http://www.yourdomain.com/html/js/barebone.jsp?mini fierType=js&minifierBundleId=javascript. barebone.files and save file as barbone.jsp.

  • Same way, http://www.yourdomain.com/html/js/ everything.jsp?minifierType=js&minifierBundleId =javascript.everything.files. and save it as everything.jsp

  • Put saved barebone.jsp and everything.jsp under $apache_static_resources/html/js/ directory and serve as static resource. If you use proxypass add following rule in .htaccess/virtualhost file.


ProxyPass /html/js/barebone.jsp !
ProxyPass /html/js/everything.jsp !


Restart Apache web server.


  1. Control browser caching


Browser caching stores static resources such as css, images, js,etc. on a local computer when a user visits a webpage. When you leverage browser caching, your webpage files will get stored in the browser cache. Your pages will load much faster for repeat visitors and so will other pages that share those same resources. Change the request headers of resources to use caching to enable browser caching.


Add following rules in .htaccess/virtualhost files and enable mod_expires. Configure time period as per requirements.


<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 week"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 2 hours"
ExpiresByType application/pdf "access plus 10 minutes"
ExpiresByType text/x-javascript "access plus 1 week"
ExpiresByType application/x-shockwave-flash "access plus 1 week"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 10 minutes"


And restart you Apache web server.


Note :  If you cache css/images/js for specific time (e.g. 1 year) and you make any changes in between, users will look to cached files rather than the updated ones. You can overcome the cache issue by using URL fingerprinting.


You can also use our Performance booster hook plugin to accelerates enterprise portal experience to the next level.


For more implementation details or support you may contact us at [email protected].

contact-us Request a callback WhatsApp