AWS (S3 and CloudFront)
S3 behind CloudFront is the most common way to host a static site inside an organisation’s own cloud account, and it is where the conveniences of managed static hosts have to be rebuilt by hand: clean URLs and trailing slashes, redirects, atomic deploys, previews and rollbacks. The guides below rebuild each of them, and cover the CloudFront settings — cache policies, error caching, Origin Shield — that decide how often requests reach the bucket at all.
Choosing the Right Static Site Generator for Production
- Trailing Slash and basePath in Next.js Static ExportHow-toConfigure trailingSlash, basePath and assetPrefix in a Next.js static export so links, assets, canonicals and host URL handling agree on every static host.
Core Web Vitals Optimization for SSGs
- Cloudflare vs CloudFront Cache Hit Ratios for Static SitesComparisonCloudflare and CloudFront measured serving the same static site: cache hit ratio, origin requests, TTFB by region and cost, plus the settings that moved each.
- Cache Keys and Query Strings on CDNsHow-toStop tracking parameters from fragmenting a static site’s CDN cache: normalize query strings in the cache key on Cloudflare and CloudFront, and measure hit ratio.
- Cache-Control Headers on S3 and CloudFrontHow-toSet Cache-Control for a static site on S3 behind CloudFront: object metadata on upload, cache policies, response headers policies and invalidation, measured.
- Caching 404s and Redirects at the EdgeHow-toCache 404 pages and redirects on a static site’s CDN so bots, broken links and migration redirects stop hitting the origin, without making fixes slow to appear.
- Tiered Caching and Origin ShieldHow-toUse Cloudflare Tiered Cache or CloudFront Origin Shield so edge misses on a static site are served from a regional tier instead of the origin, with measured results.
Production-Ready Deployment & CI/CD for SSGs
- Atomic Deploys vs Incremental UploadsComparisonWhy syncing files into a live bucket serves broken pages, how atomic publishing works, and how to build atomicity yourself on S3, object storage or a VM origin.
- Blue-Green Deploys for Static SitesHow-toRun blue-green deploys for a self-hosted static site: two complete environments, verification before switching, an instant switch at the CDN and one-step rollback.
- Clean URLs and Trailing Slashes on S3How-toMake directory-style URLs work on S3 behind CloudFront: a viewer-request function for index files, one canonical trailing-slash form, and tests that prove it.
- CloudFront Functions for RedirectsHow-toServe hundreds of redirects for a static site on S3 from a CloudFront Function and KeyValueStore, generated from the build and tested on every deploy.
- Deploying Only Changed FilesHow-toUpload only the files that changed in a static site deploy using content hashes, rsync or S3 sync with checksums, while keeping the deploy atomic and purges scoped.
- Deploying a Static Site to S3 and CloudFrontHow-toDeploy a static site to a private S3 bucket behind CloudFront with Origin Access Control, split cache headers, ordered uploads and a targeted invalidation.
- Rolling Back S3 and CloudFront Deploys With Versioned PrefixesHow-toMake S3 and CloudFront deploys atomic by uploading each build to its own prefix and switching CloudFront's origin path, so a rollback takes one config change.
- Securing Deploy Credentials with GitHub OIDCHow-toReplace long-lived deploy tokens with short-lived OIDC credentials in GitHub Actions for AWS, Cloudflare and Netlify, scoped to one branch and one deploy job.
- Sharing Build Cache Across CI RunnersHow-toShare a build cache across parallel CI runners with Turborepo remote cache, an S3-backed store, or scoped actions/cache. Architecture, signing, and measured savings.
Often used with AWS (S3 and CloudFront)
- Cloudflare4 shared guidesPages and Workers hosting, cache rules and edge functions.
- Next.js1 shared guidesStatic export for content sites, its limits and alternatives.
- Netlify1 shared guidesHeaders, redirects, deploy previews and build caching.
- GitHub Actions1 shared guidesCaching, matrix builds, reusable workflows and pinning.