-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(cloudflare): add Caches bindings
- Loading branch information
1 parent
6755acd
commit 3976c39
Showing
4 changed files
with
48 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/integrations/cloudflare/test/fixtures/cf/src/pages/caches.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
import { MiniflareResponse } from "@astrojs/cloudflare"; | ||
const runtime = Astro.locals.runtime; | ||
try { | ||
await runtime.caches.default.put( | ||
'http://localhost/cache', | ||
new MiniflareResponse('true', { | ||
headers: { 'Cache-Control': 'max-age=3600', 'X-Key': 'value' }, | ||
}) | ||
); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
const response = await runtime.caches.default.match('http://localhost/cache'); | ||
const body = await response.text(); | ||
--- | ||
|
||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>CACHES</title> | ||
</head> | ||
<body> | ||
<pre id="hasCACHE">{!!runtime.caches}</pre> | ||
<pre id="hasDEFAULT">{!!body}</pre> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters