How To Configure SAP Hybris Commerce to Cache Static Assets Locally Using the Browser Cache?

There are many techniques to improve the performance of SAP Hybris Commerce, but there is one (simple) client-side technique that should not be overlooked any SAP Hybris Commerce project.

With Out-of-the-Box "OOTB" SAP Hybris Commerce, static files (JavaScript, CSS, images) are stored and served from the /_ui/ directory.

In the project.properties, there is an important property called storefront.staticResourceFilter.response.header.Cache-Control 

With OOTB Hybris Commerce, this property is set to:

storefront.staticResourceFilter.response.header.Cache-Control=no-cache,must-revalidate

Which is ideal for development purposes, since we want to minimize caching of any sort during development.

However, as your SAP Hybris Commerce implementation is nearing its go-live deployment date, it's important to re-configure this property value to resemble the following:

storefront.staticResourceFilter.response.header.Cache-Control=public,max-age=86400

This property update informs Hybris Commerce to cache the assets served from the /_ui/ directory for 24 hours from the browser cache.

If you wish to cache the static files served from /_ui/ directory for less than 24 hours, change your max-age seconds value according to your own business requirements.

Now you know how to configure SAP Hybris Commerce to cache assets locally using the user's browser cache.

About the author

Marc is the Founder of HybrisArchitect.com. He enjoys helping others learn more about SAP Hybris Commerce. Marc has held the role of Hybris Architect at Exemplis and Nasty Gal. He is a long-time Java/Spring developer. Marc holds an M.S. Software Engineering from Carnegie Mellon University and a B.S. in Accountancy from California State University, Fresno. He can be reached at: info@hybrisarchitect.com

Add a Comment

Your email address will not be published. Required fields are marked *