Skip to content

Commit b1ff771

Browse files
committed
perf(cache): tune _headers TTLs and document edge-cache staleness
- add cache rules for rss.xml, sitemap-*.xml, robots.txt - detail pages: s-maxage 1h -> 3h; lists stay 1h - annotate every block with human-readable durations - note redeploy does NOT purge the edge cache (same URL), so s-maxage is the real staleness ceiling Purge-on-deploy follow-up tracked in #92.
1 parent bbdca95 commit b1ff771

1 file changed

Lines changed: 33 additions & 8 deletions

File tree

public/_headers

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,63 @@
88
Permissions-Policy: accelerometer=(), autoplay=(), camera=(), encrypted-media=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), usb=(), web-share=(), xr-spatial-tracking=(), screen-wake-lock=(), clipboard-write=(self), fullscreen=(self)
99
Cross-Origin-Opener-Policy: same-origin
1010

11-
# Immutable assets
11+
# Immutable assets — content-hashed filenames, safe to cache forever.
12+
# 63072000 = 2 years. immutable = never even revalidate.
1213

1314
/_astro/*
1415
Cache-Control: public, max-age=63072000, immutable
1516

17+
# Fonts are versioned in the filename (lora-v36, open-sans-v43), not
18+
# content-hashed. 2 years is fine as long as we never edit a file in place.
1619
/fonts/*
1720
Cache-Control: public, max-age=63072000, immutable
1821

19-
# Rarely changing
22+
# Rarely changing, unhashed assets
2023

24+
# 604800 = 7 days
2125
/videos/*
2226
Cache-Control: public, max-age=604800
2327

28+
# 86400 = 1 day
2429
/favicon/*
2530
Cache-Control: public, max-age=86400
2631

32+
# 86400 = 1 day — OG images are rebuilt from posts on deploy
2733
/og/*.png
2834
Cache-Control: public, max-age=86400
2935

30-
# Homepage & list pages — short CDN TTL
36+
# Homepage & list pages — must show new posts soon after publish.
37+
# A redeploy does NOT purge the edge cache (same URL), so s-maxage is the
38+
# real staleness ceiling. Keep it short for lists.
39+
# max-age=0 browser always revalidates (cheap 304, always fresh)
40+
# s-maxage=3600 CDN serves cached for 1 hour
41+
# swr=86400 CDN may serve stale up to 1 day while refetching
3142

3243
/
33-
Cache-Control: public, max-age=0, s-maxage=600, stale-while-revalidate=86400
44+
Cache-Control: public, max-age=0, s-maxage=3600, stale-while-revalidate=86400
3445
/projects
35-
Cache-Control: public, max-age=0, s-maxage=600, stale-while-revalidate=86400
46+
Cache-Control: public, max-age=0, s-maxage=3600, stale-while-revalidate=86400
3647
/blog
37-
Cache-Control: public, max-age=0, s-maxage=600, stale-while-revalidate=86400
48+
Cache-Control: public, max-age=0, s-maxage=3600, stale-while-revalidate=86400
3849

39-
# Detail pages — longer CDN TTL
50+
# Detail pages — change only on edit.
51+
# s-maxage=10800 CDN serves cached for 3 hours = max wait for a fix to show
52+
# swr=86400 CDN may serve stale up to 1 day while refetching
4053

4154
/projects/*
42-
Cache-Control: public, max-age=0, s-maxage=3600, stale-while-revalidate=86400
55+
Cache-Control: public, max-age=0, s-maxage=10800, stale-while-revalidate=86400
4356
/blog/*
57+
Cache-Control: public, max-age=0, s-maxage=10800, stale-while-revalidate=86400
58+
59+
# Feeds & crawler files (production-only output)
60+
# s-maxage=3600 CDN 1 hour; swr=86400 stale up to 1 day
61+
62+
/rss.xml
63+
Cache-Control: public, max-age=0, s-maxage=3600, stale-while-revalidate=86400
64+
/sitemap-*.xml
4465
Cache-Control: public, max-age=0, s-maxage=3600, stale-while-revalidate=86400
4566

67+
# 86400 = 1 day
68+
/robots.txt
69+
Cache-Control: public, max-age=86400
70+

0 commit comments

Comments
 (0)