Skip to content

Add service CDN management commands#982

Merged
m-abdelwahab merged 2 commits into
masterfrom
mahmoud/service-cdn-management
Jun 20, 2026
Merged

Add service CDN management commands#982
m-abdelwahab merged 2 commits into
masterfrom
mahmoud/service-cdn-management

Conversation

@m-abdelwahab

@m-abdelwahab m-abdelwahab commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a top-level railway cdn command for service CDN cache management with dashboard parity through Railway's public GraphQL API.

railway cdn status
railway cdn enable
railway cdn disable
railway cdn update [options]
railway cdn purge <html|all>

All commands support the standard service selectors and JSON output:

-s, --service <SERVICE>
-e, --environment <ENVIRONMENT>
-p, --project <PROJECT_ID>
--json

Commands

railway cdn status

Shows the current CDN state for the selected service, including:

  • whether CDN is available
  • whether CDN caching is enabled
  • applied public domain status
  • HTML caching mode
  • default TTL
  • stale-while-revalidate state
  • purge-on-deploy policy
  • last HTML purge time
  • last full purge time

railway cdn enable

Enables CDN caching for the selected service.

Requires an applied public domain. If no domain is available, the command explains that CDN caching can't be enabled until a domain is added.

Uses the dashboard/default CDN settings, then reads back and displays the updated status.

railway cdn disable

Disables CDN caching for the selected service.

This does not prompt for confirmation, matching the dashboard toggle behavior. After disabling, it reads back and displays the updated status.

railway cdn update

Updates CDN caching settings for a service that already has CDN enabled.

Requires at least one setting flag:

--html-caching <auto|force|never>
--default-ttl <30m|1h|2h|4h|12h|1d|1800|3600|7200|14400|43200|86400>
--swr
--no-swr
--purge-on-deploy <off|html|all>

The command preserves existing settings that were not changed, then displays the updated status.

railway cdn purge <html|all>

Purges CDN cache for the selected service.

Supported scopes:

  • html: purge HTML cache only
  • all: purge the full CDN cache

API

Uses only Railway public GraphQL API operations:

  • serviceInstance { edgeConfig { ... } }
  • enableServiceCdn
  • disableServiceCdn
  • updateServiceEdgeConfig
  • purgeServiceCache

JSON output

JSON output includes service and environment context, CDN availability, enabled state, dashboard-facing caching settings, purge watermarks, and warnings.

Tests

Added coverage for:

  • CDN subcommand parsing, selectors, and --json
  • TTL parsing and enum validation
  • --swr / --no-swr conflicts
  • update requiring at least one setting flag
  • purge scope parsing with railway cdn purge <html|all>
  • status formatting and unavailable/disabled states
  • purge timestamp conversion and future timestamp rendering
  • Cloudflare warning detection
  • JSON output shape and internal field omission

Validated with:

cargo fmt --check
git diff --check
cargo check
cargo test

@m-abdelwahab m-abdelwahab added the release/minor Author minor release label Jun 19, 2026
@m-abdelwahab m-abdelwahab marked this pull request as ready for review June 19, 2026 18:17
@m-abdelwahab m-abdelwahab merged commit 8ba0162 into master Jun 20, 2026
6 of 7 checks passed
@m-abdelwahab m-abdelwahab deleted the mahmoud/service-cdn-management branch June 20, 2026 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release/minor Author minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant