fix: match Cache-Control no-cache directive case-insensitively#79
Open
spokodev wants to merge 1 commit into
Open
fix: match Cache-Control no-cache directive case-insensitively#79spokodev wants to merge 1 commit into
spokodev wants to merge 1 commit into
Conversation
Cache directive names are case-insensitive tokens (RFC 9111 Section 5.2), but the no-cache detection regexp only matched the lowercase spelling, so a request with Cache-Control: No-Cache was treated as cacheable and could be answered with a stale 304 instead of forcing an end-to-end reload.
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.
Cache-Controldirective names are case-insensitive tokens (RFC 9111 §5.2, previously RFC 7234 §5.2), butCACHE_CONTROL_NO_CACHE_REGEXPonly matches the lowercase spelling. A request that sendsCache-Control: No-Cache(or any other casing) is not detected asno-cache, sofresh()can returntrueand the caller answers an explicit end-to-end reload with a stale304instead of revalidating.Repro:
The fix adds the
iflag to the existing regexp, keeping the(?:^|,)/(?:,|$)boundaries so it still only matches the standalone directive and not substrings likex-no-cache. Adds a regression test.