Repository navigation
fix: honor client validators during forced revalidation - #298
Open
perfloop[bot] wants to merge 5 commits into
Open
perfloop[bot] wants to merge 5 commits into
perfloop[bot] wants to merge 5 commits into
Conversation
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
[Medium impact] The PR appears safe to merge. SummaryForced-revalidation GETs now check the client's validators separately from TAG's cache-freshness request.
Reviews (1) · Last reviewed commit: "fix: honor client validators during forc..." · Reviewed by Greptile |
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.
Forced-revalidation GETs now return a bodyless conditional response when the client's validators match the selected representation. TAG checks the client's conditions separately from its synthetic cache-freshness request.
ns/op 888.5 µs → 331.9 µs (−61.2%); medians of 9 paired runs.
The test fails without this change and passes with it.
The test fails without this change and passes with it.
Per-metric results
ns/opEach workload ran 9 paired runs.
Changes
If-None-Matchfields, respecting quoted commas and precedence over modification dates.The origin validation round trip remains necessary. HEAD keeps its separate revalidation flow, and cache metadata storage and coordination are unchanged.
Testing
TestRevalidationClientConditionsMatchOrigincompares direct-origin and gateway status, validators, range metadata, bytes and cache reads; it reproduces the discrepancy without the repair.TestCachedObjectMeta_MatchesETagHeaderchecks quoted commas with strong and weak comparison.TestNormalCacheHitRepeatedIfNoneMatchFieldschecks repeated fields on an ordinary cache hit.TestRevalidationStaleFallbackUsesClientConditionsWithoutSuccessValidationchecks conditional stale service and failure accounting.TestRevalidationBodyMissForwardsOriginalClientConditionspreserves pre-commit fallback with the original headers; this check also passes without the repair.TestRevalidationCommittedCacheReadFailureDoesNotForwardAgainpreserves an incomplete transfer without a second origin response; this check also passes without the repair.TestRevalidationChangedBodyDrainFailureStillCompletesMatching304checks a complete conditional response without publishing truncated cache content.TestRevalidationChangedRangeDrainFailureStillCompletesMatching304checks that a failed range drain retains the complete conditional response and full-object rewarm.Benchmark
proxy/revalidation_benchmark_test.goaddsBenchmarkRevalidationClientMatch. Reproduce withgo test ./proxy -run '^$' -bench '^BenchmarkRevalidationClientMatch$'. It measures a serial, matching-validator GET for a warmed 512 KiB object through the real transparent forwarder with valid SigV4, loopback HTTP origin and gateway, and an in-memory cache. Setup is outside timing; the origin round trip and complete response read are included. The metric is local elapsed time, not CPU time. Changed-origin drain and populate work remain and are not this benchmark's workload.Production frequency, object-size distribution, remote-cache cost and end-to-end savings remain unmeasured. The SDK compatibility job remains target-CI owned.
5 recorded checks pass with this change.
Generated by Perfloop.
Note
Medium Risk
Changes core GET conditional and revalidation response selection (304 vs body, stale fallback, ETag parsing), which can alter client-visible HTTP semantics for cached reads.
Overview
Forced-revalidation GETs now treat the client’s
If-None-Match/If-Modified-Sinceseparately from TAG’s synthetic upstream freshness check. After origin confirms the representation, matching validators can return a bodyless 304 without reading the cached body—addressing the ~61% latency win on matching ETag revalidations in the benchmark.ETag list parsing in
MatchesETagHeadersplits on commas only outside quotes, so tags like"a,b"and repeatedIf-None-Matchfields (merged via newclientIfNoneMatch/clientNotModifiedhelpers) behave per RFC 7232 on cache hits and revalidation paths.Revalidation flow (
revalidateAndServe): origin 304 merges response validators locally, returns client 304 when appropriate, serves cached bytes when not, or forwards the original request if the 304 updates ETag without a safe cached body. Origin 200/206 can still 304 to the client while draining the upstream body into cache update/rewarm. Stale fallback applies client conditionals without counting as successful origin validation.Docs and README describe the new conditional semantics and
X-Cachemeanings; broad integration tests andBenchmarkRevalidationClientMatchcover the behavior.Reviewed by Cursor Bugbot for commit 96a52b1. Bugbot is set up for automated code reviews on this repo. Configure here.