cdn assets.md

Deliver public assets through CDN for Next.js

Summary

Deliver public assets for a Next.js 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.

Infrastructure requirements

Prerequisites

Exact tested configuration

Steps

  1. Publish the bucket. Publishing makes objects readable at the CDN URL; keep private data in a separate, unpublished bucket.
   ample bucket publish <bucket-name>
  1. Upload versioned assets. Use keys such as assets//file and set Cache-Control: public, max-age=31536000, immutable; change the version to invalidate.
  2. Reference the CDN URL. Pass S3_PUBLIC_URL to the app and build asset URLs from it.
   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=...
  1. Verify delivery. Fetch /api/asset-url for the asset URL, then fetch that URL: the CDN must return the asset.
  2. 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.
   ample logs <deployment_id> --kind build

Tested examples

Success checks

Limitations

Cost estimate

Estimated 5.00 USD per month (size prices from pricing.toml at build revision a1b8c38919e59cd035ebabaced73cf84ece24371).

Verification evidence

Last verified: 2026-09-20T01:13:26Z

Execution binding

MCP tool ample_deploy (registry mcp:ample_deploy), schema hash 876465fce906da0c observed 2026-09-20T01:55:48.667900+00:00 at revision 199ff1dfd526, binding state current, required scopes: servers:write, buckets:write.