Fix Cache-Control header of non-versioned assets#37010
Merged
szaimen merged 1 commit intonextcloud:masterfrom Mar 14, 2023
Merged
Fix Cache-Control header of non-versioned assets#37010szaimen merged 1 commit intonextcloud:masterfrom
szaimen merged 1 commit intonextcloud:masterfrom
Conversation
MichaIng
reviewed
Mar 5, 2023
85870b5 to
9b9f2c7
Compare
MichaIng
approved these changes
Mar 5, 2023
Non-cache-busted assets such as /dist/core-main.js also matched the regex meant for cache-busted assets (note the ? at the end of the regex). The FilesMatch directive for cache-busted assets coming after the non-cache-busted version all assets actually got the immutable flag in their Cache-Control header. This caused client-side errors on updates. Query strings are not actually passed to FilesMatch directives so we need another way to tell cache-busted/versionned assets apart from non-versioned assets, here using If/Else directives. Signed-off-by: Nicolas Guichard <nicolas@guichard.eu>
9b9f2c7 to
7aae6c1
Compare
|
Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22 |
Member
|
/backport to stable26 |
Member
|
/backport to stable25 |
Member
|
/backport to stable24 |
Merged
This was referenced Mar 15, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
After updating from Nextcloud 24 to Nextcloud 25 people started to complain about an empty landing page until they refreshed the page ignoring their local cache (aka Ctrl+F5).
I noticed that all assets including non-cache-busted ones (such as /dist/core-main.js) had their
Cache-Controlheader set toimmutableso the browsers didn't even send conditional requests to check if a new version was available.TODO
This prevents the issue for users who don't have the files cached yet but does not fix existing caches, only implementing cache-busting for all assets would solve that. Should it be added to a list of known bugs somewhere?
This was introduced by 7dddbd0 so should be backported to NC 24 and 25 I think.
Checklist