Skip to content

fix: cache revalidation, UPDATING status, and x-cache-key encoding#70

Merged
aui merged 2 commits into
mainfrom
fix/cache-revalidation-and-status
Jun 17, 2026
Merged

fix: cache revalidation, UPDATING status, and x-cache-key encoding#70
aui merged 2 commits into
mainfrom
fix/cache-revalidation-and-status

Conversation

@aui

@aui aui commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix 304 background revalidation persistence: store revalidatedPolicy directly instead of rebuilding from stale response headers, so the next request returns fresh HIT with Age: 0
  • Add UPDATING cache status for stale-while-revalidate (Cloudflare CDN alignment); reserve STALE for stale-if-error
  • Return 304 Not Modified from Cache.match() when If-None-Match / If-Modified-Since match a fresh cached entry
  • Percent-encode x-cache-key header values so cache keys with control characters or non-Latin-1 Unicode are valid HTTP header field values
  • Strip persisted Age from stored policy metadata on read for compatibility with legacy entries
  • Update README cache status and standards compliance docs

Test plan

  • npm test (272 tests passed)

Fix 304 background revalidation persistence so subsequent requests return
fresh HIT, add UPDATING for stale-while-revalidate, return 304 from
match for conditional requests, and percent-encode x-cache-key values.
@changeset-bot

changeset-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2830219

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@web-widget/shared-cache Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.62162% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/cache.ts 96.31% 8 Missing and 1 partial ⚠️
src/index.ts 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Use STALE for stale-if-error on origin errors, omit body headers on
conditional 304 responses, rename cachedBody to storedBody, and add
tests for conditional match edge cases and non-storable revalidation.
@aui aui merged commit e7a9731 into main Jun 17, 2026
3 checks passed
@aui aui deleted the fix/cache-revalidation-and-status branch June 17, 2026 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant