fix: don't let props-only loaders veto the page cache (Algolia, VTEX proxy, std redirects, commerce wrappers)
Problem
deco's loader wrapper defaults cache to no-store. Since the page-cache decision honors loader vetoes (vary.shouldCache = false), a page that resolves any loader without a cache export answers Cache-Control: no-store, no-cache, must-revalidate. On deco versions from before the veto, the same pages were public, max-age=90, …, so a deco bump silently turns off CDN and page caching for them.
These loaders only map their props (and, for Algolia, the request URL) and never had a cache export:
algolia/loaders/product/{listingPage,list,suggestions}.ts: a site with an Algolia loader in a global block (e.g. a header search loader) getsno-storeon every page.vtex/loaders/proxy.tsandcompat/std/loaders/x/redirects.ts: route loaders, resolved on every request, so every page of a site whose routes include them becomesno-store.
Fix
export const cache = "no-cache" on each. They stay uncached (as today), but they no longer veto the page cache.
Tested
With these files mapped in through a local import-map override, on deco 1.217.0:
- On a site whose header resolves the Algolia listing loader, home, PLP and PDP went from
no-storetopublic, max-age=90, stale-while-revalidate=3600, stale-if-error=86400. - On a site whose routes include the VTEX proxy and a std redirects block, home, PLP and PDP went from
no-storetopublic, …. The veto was traced to exactly these two loaders by logging wherevary.shouldCacheis set. - HTML is unchanged on both sites. Search pages with a VTEX IS loader keep
no-storewhere it returns a null cache key (expected).
Also (added): commerce/loaders/product/productListingPage.ts and products.ts, the deprecated extension wrappers, get cache = "no-cache", like commerce/loaders/product/extensions/* already have. Without it, a page that extends a PLP answered no-store.
🤖 Generated with Claude Code
Summary by CodeRabbit
- Bug Fixes
- Product listings, product suggestions, and redirect pages no longer automatically prevent page-level caching.
- Proxy routes now use the same cache behavior, allowing caching to follow the page’s settings.
- Product pages that use extended loaders retain caching behavior determined by those loaders.