Skip to content
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

Fix Cache-Control header of non-versioned assets #37010

Merged

Conversation

nicolas-guichard
Copy link
Contributor

@nicolas-guichard nicolas-guichard commented Mar 2, 2023

  • Resolves: I found no related issue, do I need to create one?

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-Control header set to immutable so 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.

  • backport to stable25
  • backport to stable24

Checklist

@solracsf solracsf requested a review from CarlSchwan March 2, 2023 20:34
Copy link
Member

@solracsf solracsf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes perfectly sense IMO

@solracsf solracsf added this to the Nextcloud 26 milestone Mar 2, 2023
@szaimen szaimen added the 3. to review Waiting for reviews label Mar 2, 2023
@szaimen szaimen requested review from juliusknorr and artonge March 2, 2023 23:05
@MichaIng MichaIng modified the milestones: Nextcloud 26, Nextcloud 27 Mar 5, 2023
.htaccess Outdated Show resolved Hide resolved
@nicolas-guichard nicolas-guichard force-pushed the bugfix-cache-control-immutable branch from 85870b5 to 9b9f2c7 Compare March 5, 2023 11:34
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>
@szaimen szaimen force-pushed the bugfix-cache-control-immutable branch from 9b9f2c7 to 7aae6c1 Compare March 11, 2023 17:18
@szaimen szaimen merged commit 2b291e7 into nextcloud:master Mar 14, 2023
@welcome
Copy link

welcome bot commented Mar 14, 2023

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

@MichaIng
Copy link
Member

/backport to stable26

@MichaIng
Copy link
Member

/backport to stable25

@MichaIng
Copy link
Member

/backport to stable24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants