fix(compat/std): don't let the VTEX wrapper loaders veto the page cache

GU
6d ago
+50-0

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. The vtex loader they invoke still caches and vetoes on its own terms (a null cache key still makes the page no-store).
  • navbar.ts already re-exports the vtex loader's cache, 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-store to public, 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 invoked vtex/loaders/proxy.ts (#1712). After: none of them.
  • Still no-store, and not changed here:
    • Search (?q=): the IS loader returns a null key, as on any site.
    • Pages with deco-sites/std/loaders/vtex/intelligentSearch/productList.ts shelves: the wrapper calls the vtex loader through ctx.invoke, so it sees ctx.isInvoke and returns a null cache key. Those blocks need the vtex/loaders/intelligentSearch/productList.ts loader directly, or a fix along the lines of deco-cx/deco#1244.
  • deno fmt --check and deno lint pass on compat/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/std as 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-store behavior. This keeps caching behavior consistent across both current and legacy VTEX integrations.