fix(compat/std): don't let the VTEX wrapper loaders veto the page cache
What is this Contribution About?
The compat/std VTEX loaders (deco-sites/std/loaders/vtex/intelligentSearch/*, legacy/*, proxy) only invoke the matching vtex loader, and they have no cache export. deco's loader wrapper defaults cache to no-store. Since the page-cache decision honors loader vetoes (vary.shouldCache = false, deco ≥ 1.205), every page that resolves one of these wrappers answers Cache-Control: no-store, no-cache, must-revalidate. On older deco the same pages answered public, max-age=90, …, so a deco bump silently turns off CDN caching for legacy std sites: PLPs, PDPs, shelves, header suggestions, and (through the std proxy route loader) every page.
This complements #1712, which does the same for vtex/loaders/proxy.ts, compat/std/loaders/x/redirects.ts and the Algolia loaders.
Changes
export const cache = "no-cache"on the 10 pass-through wrappers. They stay uncached themselves, as today, and stop vetoing. Thevtexloader they invoke still caches and vetoes on its own terms (anullcache key still makes the pageno-store).navbar.tsalready re-exports the vtex loader'scache, so it's unchanged.
Verification
On a legacy std site (VTEX, routes through $live/handlers/routesSelection.ts with the std proxy audience), deco 1.217.0 + apps 0.170.0, with this branch plus #1712's vtex/loaders/proxy.ts change mapped in through a local import-map override:
- PLP, PDP and an institutional page went from
no-storetopublic, max-age=90, stale-while-revalidate=3600, stale-if-error=86400. HTML is unchanged. - The vetoes were traced by logging where the loader wrapper sets
vary.shouldCache = false. Before:deco-sites/std/loaders/vtex/{intelligentSearch/productListingPage,intelligentSearch/productDetailsPage,intelligentSearch/suggestions,legacy/productDetailsPage,legacy/relatedProductsLoader,proxy}.ts, plus the invokedvtex/loaders/proxy.ts(#1712). After: none of them. - Still
no-store, and not changed here:- Search (
?q=): the IS loader returns anullkey, as on any site. - Pages with
deco-sites/std/loaders/vtex/intelligentSearch/productList.tsshelves: the wrapper calls the vtex loader throughctx.invoke, so it seesctx.isInvokeand returns anullcache key. Those blocks need thevtex/loaders/intelligentSearch/productList.tsloader directly, or a fix along the lines of deco-cx/deco#1244.
- Search (
deno fmt --checkanddeno lintpass oncompat/std/loaders.
🤖 Generated with Claude Code
Summary by cubic
Stops the compat/std VTEX wrapper loaders from vetoing the page cache, restoring CDN caching on legacy std sites after a deco bump. These wrappers defaulted to no-store, which made pages answer Cache-Control: no-store on deco versions where loaders can veto the page cache; they now export cache = "no-cache" and stay uncached themselves, letting the underlying vtex loader make the caching decision.
Migration
- No new dependencies or configuration changes; deploy
compat/stdas part of the next apps release.
Summary by CodeRabbit
- Bug Fixes
- VTEX product, listing, suggestion, related-product, and proxy experiences now pass cache handling through to the VTEX loaders instead of applying the platform’s default
no-storebehavior. This keeps caching behavior consistent across both current and legacy VTEX integrations.
- VTEX product, listing, suggestion, related-product, and proxy experiences now pass cache handling through to the VTEX loaders instead of applying the platform’s default