Commit 7e36176
fix(cache): increase stale-while-revalidate TTL to 1 hour (#1136)
* fix(cache): increase stale-while-revalidate TTL to 1 hour
- STALE_TTL_PERIOD default: 30s → 3600s (1h)
Keeps loader cache entries in LRU as stale fallback during origin
slowdowns. Previously items were evicted after 90s total (60s fresh
+ 30s stale), leaving cache misses exposed to full origin latency.
- DECO_PAGE_CACHE_CONTROL stale-while-revalidate: 30s → 3600s (1h)
CDN can serve stale HTML for up to 1h while revalidating in background,
reducing origin pressure during high latency spikes.
Both values remain overridable via env vars.
* fix(cache): add stale-if-error=86400 to page cache control
Aligns middleware PAGE_CACHE_CONTROL with the existing pattern in
routes/render.tsx. Ensures CDN serves stale HTML on origin errors
(5xx, timeout) for up to 24h, regardless of CDN implementation.
* fix(cache): prevent NaN ttl when expires header is missing
Date.parse('') returns NaN, causing ttl = NaN + STALE_TTL_PERIOD = NaN.
lru-cache disables TTL entirely when NaN is passed, making items
persist indefinitely. Fall back to STALE_TTL_PERIOD when expires is absent.
* Update cache control settings in middleware
* Change default STALE_TTL_PERIOD from 1 hour to 30 seconds
* Update runtime/middleware.ts
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
* Update middleware.ts
* Update lrucache.ts
---------
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>1 parent c3004c3 commit 7e36176
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| |||
0 commit comments