-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache Busting issues with modules loaded via liferay-npm-bundler-loader-css-loader #1182
Comments
@izaera have we run into this before? Seems like we should add some sort of mechanism, but I'm surprised if we haven't run into something like this before |
Well, this is clearly a server error. Sending Said that I understand there may be situations where the frontend needs to fix what the servers are doing wrong and we may want to provide tools for that. Meaning that we could add an option to the loader to add a parameter However, as you said, @bryceosterhaus, this is the first time we see this behavior and nobody has ever complaint about it, so I'm wondering if this has something to do with the server caching configuration... π€ Specifically I'm thinking about settings in CDNs can influence this too. And if all that is discarded, it might be an issue with some DXP version, of course. |
This sounds much better to me than a |
We have solved this issue temporarily by lowering Cache-Control TTL on our ingress. In general, long lasting Cache-Control was caused by default Liferay Header Filter configuration. See below: <filter>
<filter-name>Header Filter</filter-name>
<filter-class>com.liferay.portal.servlet.filters.header.HeaderFilter</filter-class>
<init-param>
<param-name>url-regex-ignore-pattern</param-name>
<param-value>.+/-/.+</param-value>
</init-param>
<init-param>
<param-name>Cache-Control</param-name>
<param-value>max-age=315360000, public</param-value>
</init-param>
<init-param>
<param-name>Expires</param-name>
<param-value>315360000</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Header Filter</filter-name>
<url-pattern>*.css</url-pattern>
</filter-mapping> I predict such default filters configuration assumes .css URI has format like:
Without this cache busting part there is a risk, that in some environments developers cannot update .css for users by deploying new OSGI module version. CSS stays cached on the browser side for time given in Cache Control header. Lets see Liferay.dev Portal as an example:
The main risk here is that changes made to the CSS file won't be reflected for users until their browsers refresh the cache after the specified max-age duration. Without cache busting, you have limited control over when users receive updated styles. If you make frequent changes to the CSS, users might experience outdated styles until the cache expires. If there are critical updates (imagine payment module bug) or fixes in your CSS, users may experience issues until their browser fetches the latest version. |
Issue type (mark with
x
)Version (mark with
x
)Description
I have .scss file imported in react component via: import './../../css/sector.scss';
For this file i have a module sector.scss.js generated with contents like given below:
It adds link element with href without any timestamp (eg. /o/com-test-web/css/sector.css), version or cache busting suffix. It makes it impossible to properly cache those kind of files via cdn.
Desired behavior:
Generated href should consist cache busting fragment: timestamp, module version or file hash.
For example: /o/com-test-web/css/sector.css?t=1686646309656
Current behavior:
Generated href consists no cache busting fragment.
What is more, Liferay server sets header to: Cache-Control: max-age=315360000, public
Combination of those two issues makes it impossible to properly cache those kind of files via cdn.
Repro instructions (if applicable):
npm run build
Other information (environment, versions etc):
LINUX,
com.liferay.gradle.plugins.workspace version: 3.4.27
@liferay/npm-scripts version 47.0.0
liferay-npm-bundler-loader-css-loader version: 2.24.2
Liferay version: 7.4.3.33-ga33
The text was updated successfully, but these errors were encountered: