Cloudflare
Cloudflare shows up across every section of the site because it is several products at once for a static site: a host (Pages and Workers static assets), a CDN in front of other hosts, and an edge runtime for the handful of dynamic routes a static site needs. The guides below cover all three — deploying Astro and Hugo, headers and redirects, cache keys and tiered caching, Early Hints, middleware, rate limiting, and keeping previews private with Access.
Where a guide compares Cloudflare with another platform, the comparison is measured on the same build; where it describes a platform limit, the limit is stated with the date it was checked, because Cloudflare’s static offering has changed more than any other host’s in the last two years.
Choosing the Right Static Site Generator for Production
- Language Detection and Redirects at the EdgeHow-toRedirect first-time visitors to their language with a Cloudflare Worker on the root URL only, honour a saved choice and keep crawlers and shared links intact.
- robots.txt and noindex for Preview and StagingHow-toKeep preview, staging and platform-host copies of a static site out of search results with X-Robots-Tag headers on Netlify, Vercel and Cloudflare.
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.
- Building an Image CDN Pipeline for Static SitesHow-toWhen to offload image transforms to an image CDN versus build time: URL-based transforms, edge caching, and cost, compared across Cloudflare Images, imgix, and Netlify.
- 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 Cloudflare PagesHow-toSet Cache-Control on Cloudflare Pages with a _headers file and Cache Rules — year-long immutable assets, revalidated HTML, and CF-Cache-Status HIT verified with curl.
- Early Hints (103) on CloudflareHow-toSend 103 Early Hints from Cloudflare for a static site so browsers start fetching CSS, fonts and the LCP image before the HTML arrives, and measure when it helps.
- Precompressing Assets with Brotli and ZstdHow-toPrecompress static site output at build time with brotli 11 and zstd 19, serve the variants from Caddy, nginx or Cloudflare, and measure the transfer saving.
- Serving Astro Images Through Cloudflare Image ResizingHow-toMove Astro image processing from build time to Cloudflare Images transformations with a custom image service, cutting build time while keeping srcset and AVIF.
- 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.
- Fixing Stale HTML After Deploys on CloudflareFixFind why readers see old pages after a deploy on Cloudflare, from Cache Everything rules and browser max-age to service workers, and fix each with a test.
Production-Ready Deployment & CI/CD for SSGs
- Netlify Functions vs Cloudflare WorkersComparisonThe same three functions on Netlify and Cloudflare, measured: cold starts, global latency, limits, local development, storage and cost for a static site.
- Static Site Bandwidth Pricing: Netlify, Vercel, CloudflareComparisonModel monthly hosting cost for a static site on Netlify, Vercel and Cloudflare at four traffic levels, with the levers that cut bandwidth by half or more.
- Adding a Contact Form with Cloudflare WorkersHow-toBuild a contact form for a static site on Cloudflare: a Pages Function that validates, checks Turnstile, rate-limits, stores in D1 and emails the team.
- Automating Eleventy Deployments on Cloudflare PagesHow-toDeploy Eleventy from Git on Cloudflare Pages: connect the repo, set the build command and _site output, pin Node, wire env vars, and ship cache headers — with build times.
- Branch Deploy Controls on Cloudflare PagesHow-toControl which branches build and deploy on Cloudflare Pages, name preview aliases, skip builds for docs-only changes and keep preview traffic private and cheap.
- Cloudflare Pages Functions MiddlewareHow-toUse _middleware.js in Cloudflare Pages Functions to add headers, auth, redirects and A/B routing to a static site, scoped by path and measured for latency and cost.
- Configuring Redirects on Cloudflare PagesHow-toWrite a _redirects file for Cloudflare Pages, know its limits, and move large or dynamic rule sets to Bulk Redirects or a Worker without slowing requests.
- Custom Domains and TLS on Cloudflare PagesHow-toAttach apex and www domains to Cloudflare Pages, understand how certificates are issued, choose the right SSL mode, and fix the common validation failures.
- Deploying Astro to Cloudflare Workers Static AssetsHow-toDeploy a static Astro site to Cloudflare Workers with static assets: wrangler config, trailing slashes, 404 handling, headers, previews and optional server routes.
- Deploying Hugo to Cloudflare Pages and WorkersHow-toDeploy a Hugo site to Cloudflare Pages — pin HUGO_VERSION, set the build command and public output dir — and learn when Workers and Wrangler earn their place.
- Deploying to Cloudflare From GitHub Actions With WranglerHow-toDeploy a static site to Cloudflare Workers Static Assets or Pages from GitHub Actions with Wrangler: scoped tokens, PR previews, caching and rollback.
- Migrating from Cloudflare Pages to Workers Static AssetsHow-toMove a static site from Cloudflare Pages to Workers static assets: wrangler config, _headers and _redirects, previews and a zero-downtime domain cutover.
- Password-Protecting Preview DeploymentsHow-toKeep pull request previews private with platform protection, Cloudflare Access or a small edge function, and keep them out of search indexes with noindex.
- Protecting a Static Site Behind AuthenticationHow-toGate a static site or one section of it behind single sign-on with Cloudflare Access or an edge JWT check, without leaking pages through caches or search.
- 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.
- Fixing Redirect Loops on Cloudflare PagesFixDiagnose too many redirects on Cloudflare Pages, from SSL mode and trailing-slash rules to _redirects patterns and Page Rules, and fix each with a curl trace.
Often used with Cloudflare
- Netlify5 shared guidesHeaders, redirects, deploy previews and build caching.
- AWS (S3 and CloudFront)4 shared guidesS3 and CloudFront: clean URLs, cache policies and deploys.
- Vercel2 shared guidesNon-Next.js generators, the Build Output API and caching.
- Eleventy2 shared guidesIncremental builds, image pipelines and the data cascade.
- Astro2 shared guidesIslands, content collections, astro:assets and deployment.
- GitHub Actions2 shared guidesCaching, matrix builds, reusable workflows and pinning.