|Docs

railway cdn

Manage CDN caching settings for a service.

CDN caching requires an applied public domain. Add a Railway-provided or custom domain before you enable CDN caching.

Usage

railway cdn <COMMAND> [OPTIONS]

Subcommands

SubcommandDescription
statusShow CDN settings for a service
enableEnable CDN caching
disableDisable CDN caching
updateUpdate CDN caching settings
purgePurge cached content

Options

FlagDescription
-s, --service <SERVICE>Service name or ID
-e, --environment <ENVIRONMENT>Environment to use
-p, --project <PROJECT_ID>Project ID to use
--jsonOutput in JSON format

Examples

Show CDN settings

railway cdn status --service web

Shows whether CDN caching is available and enabled for the selected service.

Enable CDN caching

railway cdn enable --service web

Enables CDN caching with Railway's default settings.

Configure HTML caching and TTL

railway cdn update \
  --html-caching force \
  --default-ttl 4h

Sets HTML caching to force and the fallback TTL to 4 hours.

Configure stale-while-revalidate

railway cdn update --no-swr

Disables honoring stale-while-revalidate directives from your service.

Configure purge on deploy

railway cdn update --purge-on-deploy all

Clears all cached content after each successful deploy.

Purge cached HTML

railway cdn purge html

Clears cached HTML responses and leaves static assets in place.

Purge all cached content

railway cdn purge all

Clears all cached content for the service.

Disable CDN caching

railway cdn disable --service web

Disables CDN caching for the selected service.

Options for

Use railway cdn update with one or more setting flags.

FlagDescription
--html-caching <auto|force|never>Controls when HTML responses are cached
--default-ttl <TTL>Fallback TTL: 30m, 1h, 2h, 4h, 12h, 1d, or matching seconds
--swrHonor stale-while-revalidate directives
--no-swrIgnore stale-while-revalidate directives
--purge-on-deploy <off|html|all>Configure automatic cache purge after successful deploys

Arguments for

ArgumentDescription
<html|all>Cache scope to purge