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
| Subcommand | Description |
|---|---|
status | Show CDN settings for a service |
enable | Enable CDN caching |
disable | Disable CDN caching |
update | Update CDN caching settings |
purge | Purge cached content |
Options
| Flag | Description |
|---|---|
-s, --service <SERVICE> | Service name or ID |
-e, --environment <ENVIRONMENT> | Environment to use |
-p, --project <PROJECT_ID> | Project ID to use |
--json | Output in JSON format |
Examples
Show CDN settings
railway cdn status --service webShows whether CDN caching is available and enabled for the selected service.
Enable CDN caching
railway cdn enable --service webEnables CDN caching with Railway's default settings.
Configure HTML caching and TTL
railway cdn update \
--html-caching force \
--default-ttl 4hSets HTML caching to force and the fallback TTL to 4 hours.
Configure stale-while-revalidate
railway cdn update --no-swrDisables honoring stale-while-revalidate directives from your service.
Configure purge on deploy
railway cdn update --purge-on-deploy allClears all cached content after each successful deploy.
Purge cached HTML
railway cdn purge htmlClears cached HTML responses and leaves static assets in place.
Purge all cached content
railway cdn purge allClears all cached content for the service.
Disable CDN caching
railway cdn disable --service webDisables CDN caching for the selected service.
Options for
Use railway cdn update with one or more setting flags.
| Flag | Description |
|---|---|
--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 |
--swr | Honor stale-while-revalidate directives |
--no-swr | Ignore stale-while-revalidate directives |
--purge-on-deploy <off|html|all> | Configure automatic cache purge after successful deploys |
Arguments for
| Argument | Description |
|---|---|
<html|all> | Cache scope to purge |