{"_id":"@appwrite.io/cdn-for-astro","name":"@appwrite.io/cdn-for-astro","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@appwrite.io/cdn-for-astro","description":"Route caching for Astro sites hosted on Appwrite","version":"1.0.0","type":"module","author":{"name":"Appwrite"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/appwrite/cdn-for-astro.git"},"keywords":["appwrite","astro","astro-integration","cache","cdn"],"bugs":{"url":"https://github.com/appwrite/cdn-for-astro/issues"},"homepage":"https://github.com/appwrite/cdn-for-astro#readme","sideEffects":false,"exports":{".":"./dist/index.js","./cache":"./dist/cache/index.js","./cache/provider":"./dist/cache/provider.js","./package.json":"./package.json"},"engines":{"node":">=22.12.0"},"scripts":{"build":"tsc -p tsconfig.json","dev":"tsc -p tsconfig.json --watch","clean":"rm -rf dist","format":"biome format --write","format:check":"biome format","lint":"biome lint","lint:fix":"biome lint --write","check":"biome check --write","typecheck":"tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json","pretest":"npm run build","test":"node --test","test:coverage":"node --test --experimental-test-coverage","package:check":"publint && attw --pack --profile esm-only","changeset":"changeset","version":"changeset version","prepare":"simple-git-hooks"},"dependencies":{"node-appwrite":"^28.0.0"},"peerDependencies":{"astro":"^7.0.0"},"devDependencies":{"@arethetypeswrong/cli":"^0.18.2","@biomejs/biome":"^2.5.3","@changesets/cli":"^2.29.7","@types/node":"^22.10.6","astro":"^7.2.2","lint-staged":"^16.2.7","publint":"^0.3.14","simple-git-hooks":"^2.13.1","typescript":"^5.9.2"},"simple-git-hooks":{"pre-commit":"npx lint-staged"},"lint-staged":{"*.{js,mjs,cjs,ts,mts,cts,json,jsonc,md}":"biome check --write --no-errors-on-unmatched"},"publishConfig":{"access":"public","provenance":true},"_id":"@appwrite.io/cdn-for-astro@1.0.0","gitHead":"792f0d3d7134d945b46aa7ed8dc52f84c668a3c7","_nodeVersion":"22.23.2","_npmVersion":"10.9.8","dist":{"integrity":"sha512-fKxUGAQeiuKfUapRfU1/Sj1dQU75zilCZMeEKg+x1B3rsc0I8N4uweeR4E4jzBiRn7nWSs248mT/Uei+CtEbeg==","shasum":"c7cfbc619c9bc200787ebc2c0606ee95f86c2a7e","tarball":"https://registry.npmjs.org/@appwrite.io/cdn-for-astro/-/cdn-for-astro-1.0.0.tgz","fileCount":19,"unpackedSize":31201,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@appwrite.io%2fcdn-for-astro@1.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD17kD/IzbbrC2ocATSrXFm/zcwEw7JcuFd5MA1WvtjvwIgHas83gXu+SQMcbyy1vbVQe3pk7Q5bb3ReWQPLAvz+Q0="}]},"_npmUser":{"name":"meldiron","email":"matejbacocom@gmail.com"},"directories":{},"maintainers":[{"name":"chirag_at_appwrite","email":"chirag@appwrite.io"},{"name":"torstendittmann","email":"torsten.dittmann@gmail.com"},{"name":"jakebarnby","email":"jakeb994@gmail.com"},{"name":"christyjacob","email":"christy@appwrite.io"},{"name":"meldiron","email":"matejbacocom@gmail.com"},{"name":"dylang64","email":"dylan@appwrite.io"},{"name":"eldadfux","email":"eldad.fux@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cdn-for-astro_1.0.0_1787239514427_0.6855135725581074"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-20T15:25:14.245Z","1.0.0":"2026-08-20T15:25:14.631Z","modified":"2026-08-20T15:25:15.042Z"},"maintainers":[{"name":"chirag_at_appwrite","email":"chirag@appwrite.io"},{"name":"torstendittmann","email":"torsten.dittmann@gmail.com"},{"name":"jakebarnby","email":"jakeb994@gmail.com"},{"name":"christyjacob","email":"christy@appwrite.io"},{"name":"meldiron","email":"matejbacocom@gmail.com"},{"name":"dylang64","email":"dylan@appwrite.io"},{"name":"eldadfux","email":"eldad.fux@gmail.com"}],"description":"Route caching for Astro sites hosted on Appwrite","homepage":"https://github.com/appwrite/cdn-for-astro#readme","keywords":["appwrite","astro","astro-integration","cache","cdn"],"repository":{"type":"git","url":"git+https://github.com/appwrite/cdn-for-astro.git"},"author":{"name":"Appwrite"},"bugs":{"url":"https://github.com/appwrite/cdn-for-astro/issues"},"license":"MIT","readme":"# Appwrite CDN for Astro\n\n[![NPM Version](https://img.shields.io/npm/v/@appwrite.io/cdn-for-astro?style=flat-square)](https://www.npmjs.com/package/@appwrite.io/cdn-for-astro)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/appwrite/cdn-for-astro/ci.yml?branch=main&style=flat-square)](https://github.com/appwrite/cdn-for-astro/actions/workflows/ci.yml)\n![License](https://img.shields.io/github/license/appwrite/cdn-for-astro.svg?style=flat-square)\n[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)\n\nOfficial Appwrite CDN cache adapter for Astro 🚀\n\nThis package brings [route caching](https://docs.astro.build/en/guides/caching/) to Astro sites hosted on [Appwrite](https://appwrite.io/). Cache hits are served by the Appwrite CDN, so the site's function is never invoked for them.\n\n![Appwrite](https://github.com/appwrite/appwrite/raw/main/public/images/github.png)\n\n## Installation\n\n```bash\nnpm install @appwrite.io/cdn-for-astro\n```\n\nAppwrite Sites runs Astro through [`@astrojs/node`](https://docs.astro.build/en/guides/integrations-guide/node/), which stays the adapter. This package supplies the cache provider next to it:\n\n```js\n// astro.config.mjs\nimport { cacheAppwrite } from '@appwrite.io/cdn-for-astro';\nimport node from '@astrojs/node';\nimport { defineConfig } from 'astro/config';\n\nexport default defineConfig({\n  adapter: node({ mode: 'standalone' }),\n  cache: {\n    provider: cacheAppwrite(),\n  },\n  routeRules: {\n    '/blog/[...path]': { maxAge: 300, swr: 60 },\n  },\n});\n```\n\n`Astro.cache.set()`, `routeRules` and `cache.invalidate()` then behave as documented. Cache directives are sent as `Appwrite-CDN-Cache-Control` and cache tags as `Appwrite-CDN-Cache-Key`; the Appwrite edge rewrites both into whatever the CDN in front of the domain speaks, and `cache.invalidate()` purges by cache key or by path through the Appwrite API.\n\nFor `cache.invalidate()` to be allowed to purge, the site's dynamic API key needs the `proxy.invalidations.write` scope (Appwrite console → your site → **Settings** → **Scopes**). Caching itself works without it.\n\nA runnable site covering all of this lives in [`examples/basic`](./examples/basic).\n\n## Requirements\n\n- Astro `^7.0.0`\n- Node.js `>=22.12.0`, which is what Astro 7 itself requires\n\n## Options\n\nEvery option is optional; the defaults suit a site deployed on Appwrite Sites.\n\n| Option      | Default                                                             | Description                                                                                                                        |\n| ----------- | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |\n| `domain`    | the domain of the request being served                              | Domain(s) purged by `cache.invalidate()`. A purge only clears the domain it names, so a site on several domains has to list them.  |\n| `endpoint`  | `APPWRITE_FUNCTION_API_ENDPOINT`, then `APPWRITE_SITE_API_ENDPOINT` | Appwrite API endpoint. Required, so pass it when neither variable is set.                                                          |\n| `projectId` | `APPWRITE_FUNCTION_PROJECT_ID`, then `APPWRITE_SITE_PROJECT_ID`     | Appwrite project ID.                                                                                                               |\n| `apiKey`    | the `x-appwrite-key` request header, then `APPWRITE_API_KEY`        | Key used to invalidate. Prefer the default: a value set here is baked into the build output.                                       |\n| `noStore`   | `true`                                                              | Send `no-store` for responses that declare no cache intent, so the CDN's default TTL cannot cache a route that never asked for it. |\n\n## Exports\n\n```js\nimport { cacheAppwrite, AppwriteCacheError } from '@appwrite.io/cdn-for-astro';\nimport { cacheAppwrite } from '@appwrite.io/cdn-for-astro/cache'; // same thing\n```\n\n`AppwriteCacheError` is what `cache.invalidate()` throws when it cannot work out which domain,\nendpoint, project or key to purge with. Catch it to tell a misconfiguration apart from a failed\nAPI call:\n\n```ts\ntry {\n  await cache.invalidate({ tags: ['products'] });\n} catch (error) {\n  if (error instanceof AppwriteCacheError) {\n    // Nothing was sent: the provider could not resolve what to purge.\n  }\n  throw error;\n}\n```\n\n## Good to know\n\n- **Cache keys are normalized.** The edge splits `Appwrite-CDN-Cache-Key` on whitespace and re-joins the keys with commas for the CDN's `Cache-Tag`, so a tag containing whitespace, a comma or a non-ASCII character is percent-encoded — identically on the response and on the purge. A tag longer than 128 characters once encoded cannot be named by a purge, so it is dropped with a warning; the response is still cached.\n- **A purge is one API call per reference per domain**, and invalidations are rate limited to 60 per minute.\n- **A path purge clears the exact path**, not copies cached under the same path with a query string. Tag those and purge by tag instead.\n- **To purge a whole domain**, call `createInvalidation({ domain, type: 'all' })` directly — Astro's `invalidate()` has no equivalent.\n- **Caching is a no-op in `astro dev`.** Astro disables it in dev, so inspect headers against a build.\n\n## Contributing\n\nBug reports and pull requests are welcome. See [CONTRIBUTING.md](./CONTRIBUTING.md) for the\ndevelopment setup, and [SECURITY.md](./SECURITY.md) for reporting a vulnerability.\n\n## Support\n\n- Join the [Appwrite Discord](https://appwrite.io/discord) for help with Appwrite Sites and the CDN.\n- Read the [Appwrite documentation](https://appwrite.io/docs) and the [Astro caching guide](https://docs.astro.build/en/guides/caching/).\n- Submit bug reports and feature requests as [GitHub issues](https://github.com/appwrite/cdn-for-astro/issues).\n\n## License\n\nMIT — see [LICENSE](./LICENSE).\n","readmeFilename":"README.md","_rev":"1-7ad08cebeadcb4bdcfba4ea28c65ac25"}