Skip to content

Commit a2cb294

Browse files
committed
made into note, simplified code example
1 parent 3d7bdaa commit a2cb294

File tree

1 file changed

+5
-5
lines changed
  • src/content/docs/workers/runtime-apis

1 file changed

+5
-5
lines changed

src/content/docs/workers/runtime-apis/cache.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ You may create and manage additional Cache instances via the [`caches.open`](htt
4949
let myCache = await caches.open('custom:cache');
5050
await myCache.match(request);
5151
```
52+
:::note
5253
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.
5354

5455
```js
55-
async fetch(request, env, ctx) {
56-
// avoid overriding the request URL or passing a new request into the cache API
57-
request.url = "https://some-overridden-value.com";
56+
// avoid overriding the URL in request or passing a new request into the cache API
57+
request.url = "https://some-overridden-value.com/";
5858

5959
let myCache = await caches.open('custom:cache');
60-
await myCache.match(request);
61-
},
60+
let response = await myCache.match(request);
6261
```
62+
:::
6363
***
6464

6565
## Headers

0 commit comments

Comments
 (0)