feat(static): add opt-in Cache-Control via maxAge/immutable - #273
Conversation
`serveStatic()` gains two options, both off by default: - `maxAge` (seconds) emits `Cache-Control: max-age=<n>` - `immutable` appends `, immutable` (only alongside `maxAge`) The header rides along on `304 Not Modified` responses too, so a revalidation refreshes the client's stored freshness (RFC 9110 §15.4.5), but is omitted on `412` and on `renderHTML` routes. A fractional or negative `maxAge` is floored and clamped to a valid delta-seconds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 23 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
`buildCacheControl` floored and clamped negative/fractional `maxAge` but passed `NaN`, `Infinity`, and very large numbers straight through, emitting malformed headers like `max-age=NaN` or `max-age=1e+21`. Fall back to 0 for non-finite input and cap at the RFC 9111 recommended ceiling of 2^31 seconds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary
Adds opt-in
Cache-Controlsupport toserveStatic(), complementing theETag/Last-Modifiedvalidators added in #269. Both new options are off by default, so behavior is unchanged unless a lifetime is set.maxAge— freshness lifetime in seconds, emitted asCache-Control: max-age=<n>. Lets a client reuse a response without a request until it goes stale.immutable— appends, immutable(only takes effect alongsidemaxAge). Skips revalidation even on an explicit reload — appropriate for fingerprinted, content-hashed assets.Details
304 Not Modifiedresponses too, so a revalidation refreshes the client's stored freshness (RFC 9110 §15.4.5). It is omitted on412 Precondition Failedand, like the validators, onrenderHTMLroutes.maxAgeis floored and clamped to a valid non-negativedelta-seconds.Tests
Added a
Cache-Controldescribe block covering: default omission,max-ageemission,immutable, floor/clamp,immutable-without-maxAgeno-op, presence on304/HEADand absence on412/renderHTML. Full suite: 137 passed, typecheck clean.Docs updated in
docs/1.guide/4.middleware.md.🤖 Generated with Claude Code