https://github.com/snuffydev/adapter-cloudflare-cache
Temporary SvelteKit adapter for Cloudflare Workers to enable caching
https://github.com/snuffydev/adapter-cloudflare-cache
cloudflare cloudflare-workers svelte sveltekit sveltekit-adapter
Last synced: 3 months ago
JSON representation
Temporary SvelteKit adapter for Cloudflare Workers to enable caching
- Host: GitHub
- URL: https://github.com/snuffydev/adapter-cloudflare-cache
- Owner: snuffyDev
- Created: 2021-07-29T14:41:16.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-08-18T10:23:05.000Z (almost 4 years ago)
- Last Synced: 2025-01-11T16:48:48.745Z (5 months ago)
- Topics: cloudflare, cloudflare-workers, svelte, sveltekit, sveltekit-adapter
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@snuffydev/adapter-cloudflare-cache
- Size: 11.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# adapter-cloudflare-cache
# WARNING!
> This adapter is ***not*** considered stable, not recommended for production use.
This adapter implements SvelteKit Issue [#1771](https://github.com/sveltejs/kit/pull/1771), which adds cache configuration to Cloudflare Workers. Mainly meant to be used on my project [Beatbump](https://github.com/snuffyDev/Beatbump). I have not tested the configuration aspect, and the Intellisense info was not updated. *However*, I did update the adapter to the current latest version 1.0.0-next.17.
__*Only updates to this repo will be for bug fixes, stability, or required functionality changes.*__
### Install
```sh
npm install -D @snuffydev/adapter-cloudflare-cache
```## Original README Below
SvelteKit adapter that creates a Cloudflare Workers site using a function for dynamic server rendering.
This is very experimental; the adapter API isn't at all fleshed out, and things will definitely change.
## Configuration
This adapter expects to find a [wrangler.toml](https://developers.cloudflare.com/workers/platform/sites/configuration) file in the project root. It will determine where to write static assets and the worker based on the `site.bucket` and `site.entry-point` settings.
Generate this file using `wrangler` from your project directory
```sh
$ wrangler init --site my-site-name
```Then configure your sites build directory in the config file:
```toml
[site]
bucket = "./build"
entry-point = "./workers-site"
```The adapter accepts the following configuration properties:
| property | default | description |
|---|---|---|
| `pageCacheTTL` | `null` | Sets `cache-control` `max-age` for rendered responses if not defined. WARNING: this will apply to all page/request routes, disabled by default for security reasons. |
| `staticCacheTTL` | `60 * 60 * 24 * 90` (90 days) | Sets `cache-control` `max-age` for static assets. |
| `edgeCacheTTL` | `60 * 60 * 24 * 90` (90 days) | Sets CloudFlare Edge Cache TTL for static assets. |It's recommended that you add the `build` and `workers-site` folders (or whichever other folders you specify) to your `.gitignore`.
More info on configuring a cloudflare worker site can be found [here](https://developers.cloudflare.com/workers/platform/sites/start-from-existing)