From 93db1f8790857aaa79315279d251d4856c0a5643 Mon Sep 17 00:00:00 2001 From: Fernando Frizzatti Date: Wed, 27 May 2026 01:18:06 -0300 Subject: [PATCH] fix(matchers): declare website/matchers/random.ts cacheable=true MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The framework's page-cache decision (deco-cx/deco#1202) walks ctx.var.flags and writes Cache-Control: no-store if any flag has flag.cacheable !== true. The check is strict — undefined fails. random.ts powers every A/B test on the deco fleet ("ABTest {{{traffic}}}"). It's sticky="session", so the result is persisted in a deco_matcher_* Set-Cookie. CDNs that include that cookie in their custom cache key (the documented pattern, see deco-cx/deco#1202 release notes) get per-variant cache entries with no cross-contamination. So sticky-session random matchers ARE safe to cache; the module was just missing the explicit declaration. This unblocks PDPs and other matcher-wrapped pages from staying no-store on production fleets that have wired up the matcher cookie in their CDN config. Same pattern as website/matchers/always.ts, date.ts, site.ts, etc. Observed on lojastorra (Torra) PDP: "Teste A/B - PDP Botão Comprar" uses random.ts → flag.cacheable=undefined → page → no-store. After this fix, the page goes public, max-age=90, swr=3600. Co-Authored-By: Claude Opus 4.7 (1M context) --- website/matchers/random.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/website/matchers/random.ts b/website/matchers/random.ts index 354ab05cf..7ad666528 100644 --- a/website/matchers/random.ts +++ b/website/matchers/random.ts @@ -8,6 +8,11 @@ export interface Props { // once selected the session will reuse the same value export const sticky = "session"; +// Sticky-session matchers persist the result in a deco_matcher_* cookie, and +// CDNs are expected to include that cookie in the cache key — so per-variant +// responses get distinct cache entries and the page is safely cacheable. +export const cacheable = true; + /** * @title Random * @description Target a percentage of the total traffic to do an A/B test