fix(vtex): cache bounded legacy map= PLP shapes, keep deep facet crawl uncached
Why
#1570 made the legacy PLP cacheKey return null for any URL containing map=. deco treats a null key as no-store, so every legacy ?map= page bypasses the CDN, including the clean ones like brand links (/<brand>?map=b) and category+brand pages (/a/b?map=c,b).
The reason for #1570 (thanks @guitavano) was that bots crawl endless filter combinations. Each one is a one-off URL, and caching them pushed hot entries out of the loader cache. This PR keeps that protection and only re-enables caching for shapes with bounded cardinality.
Data (miess, Cloudflare, last 24h, GET ?map= pages)
| Shape | Requests | Unique URIs | Reuse |
|---|---|---|---|
≥3 map parts, spec filters, priceFrom, ft, or map not matching the path | 44,385 | 42,824 | ~1.0 |
≤2 parts, only c/b, matching the path | 3,140 | 1,477 | ~2.1 |
any shape with q/ft search param | 2,362 | 2,307 | ~1.0 |
So caching the deep combinations buys nothing and only churns the cache. The bounded shapes repeat.
Change
map=URLs get a key only when the map has ≤2 parts, every part iscorb, and the part count matches the path segment count. Everything else still returnsnull, same as today.- Adds
fmapandPSto the key, only when present. The loader reads both from the URL:fmapdrives the facets query andPSthe page size. Keys for URLs without them are byte-identical to before. - Search terms not in
cachedSearchTermsstill returnnull.
Tests
productListingPage_test.ts:
/brand?map=band/cat/brand?map=c,bget keys, and different maps get different keys- deep (
c,c,c),specificationFilter_*,priceFrom,ft, and mismatched map/path staynull fmap/PSvary the key- keys for URLs without
map/fmap/PSexactly match the current output - uncached search terms stay
null
deno fmt --check, deno lint and deno check vtex/mod.ts are clean.
Not done yet
Draft until it's validated on a miess-01 preview pinned to this commit, compared against production on the same URLs.
The deep facet crawl (44k req/day, ~1.9 GB) stays uncached. Reducing that is a robots.txt / bot-rule decision, not a cache one.