@edgeone/astro
v1.1.5
Published
Astro adapter for EdgeOne Pages
Readme
@edgeone/astro
This adapter allows astro to deploy your hybrid or server rendered site to EdgeOne Pages.
ISR (Incremental Static Regeneration)
ISR caches your server-rendered pages at the EdgeOne CDN and revalidates
them on a time window (stale-while-revalidate), with optional on-demand purge.
Astro has no per-page ISR export, so you enable it through the adapter's isr
option in astro.config.mjs.
Enable it
// astro.config.mjs
import { defineConfig } from 'astro/config';
import edgeone from '@edgeone/astro';
export default defineConfig({
output: 'server',
adapter: edgeone({
isr: {
routes: {
'/blog/**': { expiration: 60, tags: ['blog'] }
}
}
})
});Only on-demand (SSR) routes are eligible — prerendered/static pages are never affected.
isr option shapes
| Value | Meaning |
| --- | --- |
| true | Cache all SSR routes until explicitly purged |
| 60 (a number) | Cache all SSR routes, revalidate every 60s |
| { expiration, tags } | Default applied to all SSR routes |
| { routes: { '<glob>': { expiration, tags } } } | Per-route overrides (only the listed routes become ISR) |
| { expiration, exclude: ['<glob>'] } | A default plus route-pattern globs to skip |
Per-route config:
expiration: revalidation window in seconds.falsecaches until explicitly purged.tags: cache tags used for on-demand revalidation (see below).
At runtime an ISR route response is tagged with:
eo-cdn-cache-control: s-maxage=<expiration>, stale-while-revalidate=31536000, durable
cache-tag: <tags joined by comma>Responses carrying Set-Cookie, or cache-control: no-store | private, are
never CDN-cached (they stay dynamic), so personalized pages are safe.
On-demand revalidation (purge)
Trigger a regeneration without waiting for the window to elapse:
# purge by tag
curl -X POST https://<your-domain>/__edgeone_revalidate \
-H 'content-type: application/json' \
-d '{"token":"<PURGE_TOKEN>","tags":["blog"]}'
# purge by explicit path
curl -X POST https://<your-domain>/__edgeone_revalidate \
-H 'content-type: application/json' \
-d '{"token":"<PURGE_TOKEN>","paths":["/blog/hello"]}'The endpoint is disabled unless the PURGE_TOKEN environment variable is set,
and requests must present a matching token (or x-revalidate-token header).
Environment variables
| Variable | Purpose |
| --- | --- |
| PURGE_TOKEN | Enables and authenticates the /__edgeone_revalidate endpoint |
| IS_MAINLAND | Set to true to use the mainland-China purge API endpoint |
| SITE_HOST | Fallback host for purge URLs when the request host is unavailable |
Note: ISR cache headers are applied by the adapter at build/runtime, so they only appear on a deployed (or built) site — not under
astro dev.
Documentation
Read the @edgeone/astro docs
Support
Get help in the EdgeOne Pages Discord.
Check our Product Introduction for more on integrations.
License
MIT
