Repository navigation
Deploy: CDN cache headers for HTML and an nginx smoke test in CI - #2
Merged
Merged
Conversation
- nginx sends Cache-Control with s-maxage=3600 on HTML, sitemap and robots, so Cloudflare can serve crawlers from the edge once a Cache Rule makes HTML eligible. Browsers still revalidate every time. open_file_cache for the 10k files in the export. - scripts/nginx-smoke.mjs runs in CI against nginx:1.27-alpine with the production config: every sitemap URL answers 200 (no redirect), lowercase and hyphen-less registrations 301 to the canonical page, unknown registrations 404, and cache headers are present. Against the 20dd041 config it fails on every aircraft page with the self-redirect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a follow-up to #1. It covers the origin-load side of the 27 Oct indexing drop.
Why
On 26–27 Oct the origin slowed down (p95 1.97 s, max 30 s) and dropped two uptime checks, right while Googlebot was recrawling the site that had just tripled in size. Cloudflare answers
cf-cache-status: DYNAMIC, so every crawler fetch went all the way to the origin. On top of that, the 25 Oct deploy briefly served a self-redirect on every aircraft page, and nothing in CI would have caught it.Changes
Cache-Control: public, max-age=0, s-maxage=3600, stale-while-revalidate=86400on HTML, ands-maxage=3600on the sitemap, robots.txt and RSC.txtfiles. Browsers still revalidate every time./_next/staticand/datakeep their own headers.open_file_cachefor the ~10k files in the export.scripts/nginx-smoke.mjs(npm run nginx:smoke), run in CI againstnginx:1.27-alpinewith the production config. It checks that:Verified locally
The test ran on nginx 1.24 against the export built from main:
/aircraft/VT-AAT: 301, want 200 (Location …/aircraft/VT-AAT), which is the 25 Oct loop, so the test would have caught it.Still needed in Cloudflare (Nik)
The headers do nothing until Cloudflare is allowed to cache HTML:
vtaircrafts.in, Eligible for cache, Edge TTL Use cache-control header if present, Browser TTL Respect origin.Generated by Claude Code