Repository navigation
fix: apply configured Cache-control header on 304 responses - #205
Open
TalhaHunter101 wants to merge 1 commit into
Open
TalhaHunter101 wants to merge 1 commit into
TalhaHunter101 wants to merge 1 commit into
Conversation
Signed-off-by: Talha Shafeeq <talha.shafeeq.ts@gmail.com>
This branch has not been deployed
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.
Fixes #204
Summary
#192 changed
cachingSetCacheControlHeaderto apply the configuredCache-controldirective only forstatusCode >= 200 && statusCode < 300, settingno-storefor all other status codes. As a result,304 Not Modifiedresponses—including conditional ETag cache hits handled internally bycachingLoadByEtagas well as explicitreply.code(304).send()responses—incorrectly receivedCache-control: no-store.Per RFC 9110 §15.4.5 and RFC 9111 §4.3.4, a
304response must carry the sameCache-Controldirective that a200 OKresponse would have included so caches can retain and refresh stored freshness policies.Changes
cachingSetCacheControlHeaderinindex.jsto apply the configuredCache-controlvalue when(reply.statusCode >= 200 && reply.statusCode < 300) || reply.statusCode === 304.test/headers.test.jscovering both explicitreply.code(304).send()responses and conditional304hits served viaIf-None-MatchETag caching.npm test(26/26 unit tests with 100%c8coverage +tstycheTypeScript tests) andnpm run lint.Checklist
npm run test && npm run benchmark --if-presentand the Code of conduct