You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works with multi-package repos, or single-package repos to help you version and publish your code. You can find the full documentation for it [in our repository](https://github.com/changesets/changesets)
8
4
9
-
We have a quick list of common questions to get you started engaging with this
We have a quick list of common questions to get you started engaging with this project in [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
ALWAYS use the appropriate specialized agents for complex work:
92
85
93
-
-**technical-architect**: For designing system architecture, evaluating
94
-
technical approaches, planning major features
95
-
-**code-reviewer**: For comprehensive code review after implementing
96
-
significant code changes
97
-
-**test-engineer**: For analyzing test failures, creating new tests, and
98
-
enhancing test coverage. Should NOT fix application code - only
99
-
creates/updates test files
100
-
-**docs-author**: For creating or updating documentation, READMEs, changesets,
101
-
or PR descriptions
102
-
-**package-installer**: For installing npm packages with proper dependency
103
-
management
86
+
-**technical-architect**: For designing system architecture, evaluating technical approaches, planning major features
87
+
-**code-reviewer**: For comprehensive code review after implementing significant code changes
88
+
-**test-engineer**: For analyzing test failures, creating new tests, and enhancing test coverage. Should NOT fix application code - only creates/updates test files
89
+
-**docs-author**: For creating or updating documentation, READMEs, changesets, or PR descriptions
90
+
-**package-installer**: For installing npm packages with proper dependency management
Copy file name to clipboardExpand all lines: packages/cache-handlers/README.md
+11-31Lines changed: 11 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,14 @@
1
1
# cache-handlers
2
2
3
-
Unified, modern HTTP caching + invalidation + conditional requests built
4
-
directly on standard Web APIs (`Request`, `Response`, `CacheStorage`). One small
5
-
API: `createCacheHandler` – works on Cloudflare Workers, Netlify Edge, Deno,
6
-
workerd, and Node 20+ (with Undici polyfills).
3
+
Unified, modern HTTP caching + invalidation + conditional requests built directly on standard Web APIs (`Request`, `Response`, `CacheStorage`). One small API: `createCacheHandler` – works on Cloudflare Workers, Netlify Edge, Deno, workerd, and Node 20+ (with Undici polyfills).
- Uses only standard headers for core caching logic: `Cache-Control` (+ `stale-while-revalidate`), `CDN-Cache-Control`, `Cache-Tag`, `Vary`, `ETag`, `Last-Modified`
9
+
- Optional custom extension header: `Cache-Vary` (library-defined – lets your backend declare specific header/cookie/query components for key derivation without bloating the standard `Vary` header)
18
10
- Stale-While-Revalidate implemented purely via directives (no custom headers)
19
-
- Tag & path invalidation helpers (`invalidateByTag`, `invalidateByPath`,
No custom headers are added. While inside the SWR window the _stale_ cached
150
-
response is returned immediately and a background revalidation run is triggered
151
-
(if a `handler` was supplied).
137
+
No custom headers are added. While inside the SWR window the _stale_ cached response is returned immediately and a background revalidation run is triggered (if a `handler` was supplied).
152
138
153
139
To use a runtime scheduler (eg Workers' `event.waitUntil`):
154
140
@@ -245,21 +231,15 @@ if (validation.shouldReturn304) {
`Cache-Vary` is a _non-standard_, library-specific response header. It augments
249
-
the standard `Vary` mechanism by letting you list only the precise components
250
-
you want included in the cache key (headers, cookies, query params) without
251
-
emitting a large `Vary` header externally. The library consumes & strips it when
252
-
constructing the internal key.
234
+
`Cache-Vary` is a _non-standard_, library-specific response header. It augments the standard `Vary` mechanism by letting you list only the precise components you want included in the cache key (headers, cookies, query params) without emitting a large `Vary` header externally. The library consumes & strips it when constructing the internal key.
253
235
254
236
Add selective vary dimensions without inflating the standard `Vary` header:
Each listed dimension becomes part of the derived cache key. Standard `Vary`
261
-
remains fully respected; `Cache-Vary` is additive and internal – safe to use
262
-
even if unknown to intermediaries.
242
+
Each listed dimension becomes part of the derived cache key. Standard `Vary` remains fully respected; `Cache-Vary` is additive and internal – safe to use even if unknown to intermediaries.
Sets stale-while-revalidate directive for the CDN cache. By default the browser is sent a must-revalidate
226
-
directive to ensure that the browser always revalidates the cache with the server.
223
+
Sets stale-while-revalidate directive for the CDN cache. By default the browser is sent a must-revalidate directive to ensure that the browser always revalidates the cache with the server.
227
224
228
225
| Method | Type |
229
226
| ------ | -------------------------- |
@@ -235,10 +232,7 @@ Parameters:
235
232
236
233
#### :gear: immutable
237
234
238
-
Sets cache headers for content that should be cached for a long time and never revalidated.
239
-
The CDN cache will cache the content for the specified time, and the browser will cache the content
240
-
indefinitely without revalidating. Do not use this unless the URL is fingerprinted or otherwise unique.
241
-
Otherwise, the browser will cache the content indefinitely and never check for updates, including for new deploys.
235
+
Sets cache headers for content that should be cached for a long time and never revalidated. The CDN cache will cache the content for the specified time, and the browser will cache the content indefinitely without revalidating. Do not use this unless the URL is fingerprinted or otherwise unique. Otherwise, the browser will cache the content indefinitely and never check for updates, including for new deploys.
242
236
243
237
| Method | Type |
244
238
| ----------- | -------------------------- |
@@ -250,9 +244,7 @@ Parameters:
250
244
251
245
#### :gear: ttl
252
246
253
-
Sets the s-maxage for items in the CDN cache. This is the maximum amount of time that the CDN will cache the content.
254
-
If used with swr, the content will revalidate in the background after the max age has passed. Otherwise, the content will be
255
-
removed from the cache after the max age has passed.
247
+
Sets the s-maxage for items in the CDN cache. This is the maximum amount of time that the CDN will cache the content. If used with swr, the content will revalidate in the background after the max age has passed. Otherwise, the content will be removed from the cache after the max age has passed.
0 commit comments