page:guides:express:cdn assets

Deliver public assets through CDN for Express

Deliver public assets for an Express app through the Ample CDN. Publish a bucket with ample bucket publish, upload versioned assets with long-lived Cache-Control headers, and reference the CDN URL (https://cdn.//) from your pages. The CDN serves bucket objects; the app's own responses are still served by the app.

Representative Queries

Prerequisites

Steps to Deliver Assets

  1. Publish the bucket
    Publishing makes objects readable at the CDN URL; keep private data in a separate, unpublished bucket.
    Command: ample bucket publish

  2. Upload versioned assets
    Use keys such as assets//file and set Cache-Control: public, max-age=31536000, immutable; change the version to invalidate.

  3. Reference the CDN URL
    Pass S3_PUBLIC_URL to the app and build asset URLs from it.
    Command: ample deploy . --name <app-name> --public --env S3_PUBLIC_URL=... --env S3_ENDPOINT=... --env S3_REGION=... --env S3_BUCKET=... --env S3_ACCESS_KEY_ID=... --env S3_SECRET_ACCESS_KEY=...

  4. Verify delivery
    Fetch /asset-url for the asset URL, then fetch that URL: the CDN must return the asset.

  5. Verify
    Fetch the live URL and run the success checks below. On failure read the build log, then the runtime log, fix the cause and deploy again; do not blind-retry.
    Command: ample logs <app-name> --kind build

Examples

Success Checks

Limitations

Cost Estimate

Evidence Summary

Next Actions