CDN for SvelteKit

Cache prerendered SvelteKit pages and immutable application files. Let server routes that depend on sessions or form actions reach the application.

Example release policy
Versioned resource
/_app/immutable/start.c281.js
Refresh on publication
/docs/getting-started

Distinguish prerendered routes from server responses

Cache _app assets with long TTLs. Cache prerendered and anonymous SSR pages at Cloud CDN. Bypass form actions and session-specific routes.

Client assets at every PoP

SvelteKit assigns unique names to immutable build assets so releases can coexist in cache.

Prerendered HTML at the edge

Static SvelteKit routes are an ideal CDN cache.

Actions stay on the origin

Form actions and authenticated load functions bypass cache.

Configuration

Cloud CDN overview
  1. Connect the SvelteKit adapter origin

    Pull Node, static or other adapter output over HTTPS.

  2. Cache _app and prerendered routes

    Long TTL for hashed files. Purgeable TTL for HTML.

  3. Bypass actions and private loads

    Do not cache POST actions or cookie-varying pages.

  4. Purge on deploy

    Invalidate HTML after each production adapter deploy.

Operational outcomes

  • SvelteKit assets are cached globally
  • Prerendered pages live at the edge
  • Form actions remain dynamic
  • Deploys purge HTML

Frequently asked questions

Does this work with adapter-static?

Yes. Static output is a natural Cloud CDN origin.

Can I cache +server endpoints?

Only public GET endpoints. Mutations and authenticated JSON must bypass cache.

How should trailing-slash options be handled?

Pick one canonical URL shape and cache that. Avoid duplicating the same page under two keys.

Is Origin Shield useful for SSR?

Yes when many edges miss the same SSR route at once after a deploy or TTL expiry.