Skip to content

fix(weather): mark temperature matcher as cacheable - #1647

Open
igoramf wants to merge 1 commit into
mainfrom
fix/weather-matcher-cacheable
Open

fix(weather): mark temperature matcher as cacheable#1647
igoramf wants to merge 1 commit into
mainfrom
fix/weather-matcher-cacheable

Conversation

@igoramf

@igoramf igoramf commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Problem

Storefront homes that use a weather-targeted section (e.g. FarmRio, whose home uses weather/matchers/temperature.ts ×4) always respond with Cache-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 — otherwise applyPageCacheDecision (deco runtime/middleware.ts) hits !allFlagsCacheable and forces NO_STORE. See the contract in blocks/matcher.ts:

Default: undefined → page falls through to Cache-Control: no-store.

weather/matchers/temperature.ts never exported cacheable. Even when the weather section is deferred behind Rendering/Lazy.tsx, matchers are still evaluated in the main request (Lazy aborts loaders but not matchers), so the weather matcher registers a flag with cacheable=undefined and 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 as matchers/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.

  • Bug Fixes
    • Exported cacheable = true from weather/matchers/temperature.ts (match uses only Cf-Iplatitude/Cf-Iplongitude).
    • Avoids applyPageCacheDecision forcing no-store when this matcher runs, even if the section is lazy.

Written for commit c5c472b. Summary will update on new commits.

Review in cubic

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>
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@igoramf, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 10 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 18097eaa-4164-44ce-ac29-b0ba62b2b4d0

📥 Commits

Reviewing files that changed from the base of the PR and between a0a57a1 and c5c472b.

📒 Files selected for processing (1)
  • weather/matchers/temperature.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/weather-matcher-cacheable

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Tagging Options

Should a new tag be published when this PR is merged?

  • 👍 for Patch 0.159.8 update
  • 🎉 for Minor 0.160.0 update
  • 🚀 for Major 1.0.0 update

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant