Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/content/docs/workers/runtime-apis/cache.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```
:::note
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
// recommended approach: use your Worker hostname to ensure efficient caching
request.url = "https://your-Worker-hostname.com/";

let myCache = await caches.open('custom:cache');
let response = await myCache.match(request);
```
:::
***

## Headers
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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


Expand Down