Repository navigation
fix(crawler): ignore s-maxage and revalidate stale-while-revalidate entries with a conditional GET #2229 - #2232
Merged
Merged
Conversation
…ntries with a conditional GET #2229 Signed-off-by: Nik Cubrilovic <[email protected]>
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.
Closes #2229
Cause.
packages/crawler/src/incremental.tscalculateFreshness:cacheControlLifetimeSecondslets-maxage(shared caches only) beatmax-age, and a stale entry insidestale-while-revalidatereturnedrevalidate, whichcore/crawler.tshandled by reusing the stored body with no request (no background revalidation ever ran).max-age=300, s-maxage=3600, stale-while-revalidate=86400reused the stored page for up to 24 h.Fix.
calculateFreshnessusesmax-age, thenExpires;s-maxageis still parsed (thebad-cachingrule audits it) but no longer sets the lifetime. Thes-maxagefresh reason is removed (contract unions keep the literal for stored data).revalidatestate is removed. Inside the SWR window it returnsstalewith reasonstale-while-revalidate(kept for diagnostics), so the crawler sends If-None-Match / If-Modified-Since. 304 keeps the stored body, 200 replaces it. The cloud consumer sharescalculateFreshness, so it gets the same decision. Removed the crawlerrevalidatebranch.immutable,no-cache,no-store, staleness cap and Vary unchanged.docs/crawl.mdx,docs/configuration/output.mdx. Changelog:changelog.d/2229-private-client-freshness.fixed.md.Tests (
tests/private-client-freshness-2229.test.ts, new). Fail before on origin/main: 6 of 7 failed (unit s-maxage, s-maxage-alone, SWR, and the crawl-level +301 s changed and unchanged cases made 0 requests, plus the +200 s case's body check that I later fixed). Crawl-level: +301 s changed origin sends If-None-Match and stores the NEW body; unchanged gets 304 and keeps the old body; +200 s reuses with no request. Updated existing tests that asserted the old behaviour (incremental-freshness,cache-store;no-cache-fetch-2032drops its SWR case, whose control assumed SWR reuse).Gates. packages/crawler: typecheck, lint, format:check clean;
bun scripts/test-suites.ts --run crawler: 1186 pass, 0 fail;--checkOK;make validatein docs: 74 pass, 0 fail.Agent skill: no change.