fix(adapter-node): only send cache header when static resource is 200 #9394
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.
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 sentI 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
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.