How to modify the Cache-Control header to prevent browser caching issues
Jose L. Bango
更新
Issue
After deploying a new version of my theme, users are experiencing issues due to old Javascript files being loaded from the browser cache.
Thus, we would like to modify the Cache-Control header of those resources.
Environment
Liferay DXP 7.3
Resolution
To avoid these problems, the portal usually automatically adds parameters to these static resources that invalidate these intermediate cache layers, such as the 't' with the timestamp, and the use of the getStaticResourceURL method (see here for example).
In this regard, it should be taken into account that there is a known bug, fixed as of 7.3 Fix Pack 2: LPS-131777
Ensure that your custom development is using these methods for including those files.
If the issue persists and you still need to change the Cache-Control header, please note that it is introduced by the Header Filter in liferay-web.xml. You can create a custom servlet filter that overrides the default header settings and adjust that header according to your needs or do it with an intermediate element of your architecture.