Skip to content

Re-audits reuse stored pages for up to 24 h: crawler honours s-maxage and treats stale-while-revalidate as reuse without a request #2229

Closed

Description

@nc9

Re-audits can grade an old copy of a page for up to 24 hours after the site changes, because the crawler reuses stored pages using freshness rules meant for shared caches.

What happens. A site sends Cache-Control: public, max-age=300, s-maxage=3600, stale-while-revalidate=86400 (common on modern hosting and CDNs). After an audit stores a page, a re-audit made minutes after a deploy:

  • treats the page as fresh for 3600 s, because s-maxage wins over max-age, and reuses the stored body with no request;
  • after that, treats stale-while-revalidate as permission to reuse the stored body with no request again, for up to the 24 h staleness cap. The background revalidation that SWR assumes never happens.

The audit then reports findings the live page no longer has, and can flag the previous deploy's removed hashed assets as broken resources.

Where. packages/crawler/src/incremental.ts calculateFreshness (the s-maxage precedence and the revalidate state), used by core/crawler.ts (around the freshness short-circuit).

Expected. The crawler is a private client:

  • s-maxage (a shared-cache directive) is ignored; max-age, then Expires, set the lifetime.
  • A stale entry inside a stale-while-revalidate window is revalidated with a conditional GET (If-None-Match / If-Modified-Since), never reused without a request. A 304 keeps the stored body; a 200 replaces it.

Found from cloud feedback (private tracking issue 5096 in the squirrelscan monorepo).

Acceptance Criteria

  • calculateFreshness ignores s-maxage: for max-age=300, s-maxage=3600, a 301-second-old entry is NOT fresh.
  • An entry past max-age but inside stale-while-revalidate is revalidated with a conditional GET; the crawler never reuses its body without a request.
  • A crawl test: run 1 stores a page with max-age=300, s-maxage=3600, stale-while-revalidate=86400; the origin body changes; run 2 at +301 s sends a conditional request and reports the NEW body. A 304 from an unchanged origin keeps the stored body.
  • immutable, no-cache, no-store and the staleness cap behave as before (existing tests green).
  • A changelog.d entry describes the fix in user terms.

Activity

  1. added
    bug
    size: S
    engine
    on Nov 22, 2026
  2. added theissue type on Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugenginesize: S

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions