-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Added notes for cache request hostnames #18634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
8fecb56
bc2a26c
8f74b36
42cbc17
3d7bdaa
a2cb294
ebeb2d8
077b5f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,7 +49,17 @@ You may create and manage additional Cache instances via the [`caches.open`](htt | |
| let myCache = await caches.open('custom:cache'); | ||
| await myCache.match(request); | ||
| ``` | ||
| When using the cache API, avoid overriding the hostname in cache requests, as this can lead to unnecessary DNS lookups and cache inefficiencies. Always use the hostname that matches the domain associated with your Worker. | ||
|
|
||
| ```js | ||
| async fetch(request, env, ctx) { | ||
|
||
| // avoid overriding the request URL or passing a new request into the cache API | ||
| request.url = "https://some-overridden-value.com"; | ||
|
|
||
| let myCache = await caches.open('custom:cache'); | ||
| await myCache.match(request); | ||
| }, | ||
| ``` | ||
| *** | ||
|
|
||
| ## Headers | ||
|
|
@@ -105,10 +115,6 @@ cache.put(request, response); | |
|
|
||
|
|
||
| The `stale-while-revalidate` and `stale-if-error` directives are not supported when using the `cache.put` or `cache.match` methods. | ||
|
|
||
|
|
||
| ::: | ||
|
|
||
| #### Parameters | ||
|
|
||
|
|
||
|
|
@@ -152,10 +158,6 @@ cache.match(request, options); | |
|
|
||
|
|
||
| The `stale-while-revalidate` and `stale-if-error` directives are not supported when using the `cache.put` or `cache.match` methods. | ||
|
|
||
|
|
||
| ::: | ||
|
|
||
| #### Parameters | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.