|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

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

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

Enable CDN caching

Enables CDN caching with Railway's default settings.

Configure HTML caching and TTL

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

Configure stale-while-revalidate

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

Configure purge on deploy

Clears all cached content after each successful deploy.

Purge cached HTML

Clears cached HTML responses and leaves static assets in place.

Purge all cached content

Clears all cached content for the service.

Disable CDN caching

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