Add Cache Configuration to Pages

What is the problem you are trying to solve?

Pages in Liferay by default are not cached which makes sense given they are intended to be dynamic.

However, there can be pages where the guest view doesn’t change and yet Liferay must keep serving the page.

The only current alternative is through page header modifications to enable caching before a CDN or getting to the browser, but this can be error prone and easily fall out of sync with the page creation/management.

What is your proposed solution? (optional)

I propose adding a “Cache Enabled” checkbox on the page configuration panel along with a TTL for how long the page can be cached for. In addition, a warning would be shown indicating that a user could see a stale page as a result of enabling page caching.

The configuration would be used to set the caching headers for a page being returned to guest users by Liferay.

Even setting the TTL to 2 minutes can offload a ton of traffic from an active Liferay site with a CDN in front of it.

Having the configuration in the Liferay page level makes it easy for page creators/maintainers/admins to control the cache settings without having to change CDN rules or cache header injections by external tools/services.

3 Likes