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(adapter-node): only send cache header when static resource is 200 #9394

Merged
merged 4 commits into from
Mar 15, 2023

Conversation

cdemi
Copy link
Contributor

@cdemi cdemi commented Mar 10, 2023

Fixes #9393

During gradual deployment of an app with multiple instances, it is possible to load the main page from one server and the second request for static content goes to a server that has the old code deployed on it.

The old server, with the old code, does not yet have the new file, therefore it returns 404. So far, so good.

The problem arises, that with the return of 404, it also sends cache-control header with a high max-age and immutable. The browser and intermediate CDNs cache this response as much as they can.

Therefore even after the new server gets the new app, the CDNs and the browser need to force cache clear in order to be able to get the new static files.

It would make sense that unless the response is 200, the cache header is not sent

I have not managed to write a test for this use case, if someone could help I would be really grateful. I am also not sure if I managed to do the changeset correctly.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

@benmccann benmccann changed the title adapter-node: Only send cache header when static resource is 200. Fixes #9393 fix(adapter-node): only send cache header when static resource is 200 Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

adapter-node sends cache headers when static files are 404
3 participants