fix(weather): mark temperature matcher as cacheable - #1647
Conversation
The weather/temperature matcher derives its result from the visitor's geo (Cf-Iplatitude / Cf-Iplongitude), never from per-user identity, so it is safe to bake into cached HTML shared across visitors. Without `export const cacheable = true`, any page using this matcher gets a non-cacheable flag (cacheable=undefined), which makes applyPageCacheDecision fall through to `Cache-Control: no-store` for the whole page — even when every other matcher/loader on the page is cacheable. This silently disables full-page CDN caching on storefront homes that use a weather-targeted section. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 10 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: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ 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 |
Tagging OptionsShould a new tag be published when this PR is merged?
|
Problem
Storefront homes that use a weather-targeted section (e.g. FarmRio, whose home uses
weather/matchers/temperature.ts×4) always respond withCache-Control: no-store, no-cache, must-revalidate, so the CDN never caches the home. PLP/PDP on the same site cache normally (public, max-age=..., stale-while-revalidate=...).Root cause
A page is only eligible for full-page CDN caching when every active flag's matcher declares
cacheable: true— otherwiseapplyPageCacheDecision(decoruntime/middleware.ts) hits!allFlagsCacheableand forcesNO_STORE. See the contract inblocks/matcher.ts:weather/matchers/temperature.tsnever exportedcacheable. Even when the weather section is deferred behindRendering/Lazy.tsx, matchers are still evaluated in the main request (Lazy aborts loaders but not matchers), so the weather matcher registers a flag withcacheable=undefinedand disqualifies the whole page from caching.Fix
Declare
export const cacheable = true. The match derives only from the visitor's geo (Cf-Iplatitude/Cf-Iplongitude), never from per-user identity — the same class asmatchers/device.ts,date.ts, etc. which already declare it. The deferred weather section still resolves per-request in its own partial, so its variant is not frozen by page caching.🤖 Generated with Claude Code
Summary by cubic
Mark the weather temperature matcher as cacheable to restore full-page CDN caching on pages using weather-targeted sections. Homepages now cache normally instead of returning no-store.
cacheable = truefromweather/matchers/temperature.ts(match uses onlyCf-Iplatitude/Cf-Iplongitude).applyPageCacheDecisionforcingno-storewhen this matcher runs, even if the section is lazy.Written for commit c5c472b. Summary will update on new commits.