You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ActCache.buildActCacheKey (packages/core/lib/v3/cache/ActCache.ts:184-195) hashes the page URL verbatim from safeGetPageUrl (packages/core/lib/v3/cache/utils.ts:10-16), which is just page.url(). There's no normalization step.
As a result, URLs that are semantically equivalent — same origin, same path, same set of query parameters — produce different cache keys whenever the parameters appear in a different order. The cache silently misses.
why it matters
Real-world URLs reorder query parameters all the time. Examples:
First visit
Second visit
Same page?
Cache hits today?
?id=42&utm_source=email
?utm_source=email&id=42
yes
no
?ref=home&page=2
?page=2&ref=home
yes
no
Anything that runs through an email/SMS/ad funnel hits this, and most e-commerce / SaaS marketing URLs do. Every reordering invalidates the cache, which means an LLM call, which means cost + latency, which is the exact thing ENABLE_CACHING is meant to avoid.
proposed fix (conservative)
Sort query parameters before hashing. Strict superset of current cache hits — no current hit can become a miss, and previously-missed reorderings now hit. Nothing else changes: the stored entry.url would still be the raw URL (for debugging), only the key derivation gets normalized. No opinions on tracking-param stripping (utm_*, fbclid, etc.) and no fragment handling in this pass — both can be follow-ups if desired since they involve semantic choices.
Suggested code shape:
// in cache/utils.tsexportfunctionnormalizeUrlForCacheKey(rawUrl: string): string{if(!rawUrl)returnrawUrl;try{consturl=newURL(rawUrl);url.searchParams.sort();returnurl.toString();}catch{returnrawUrl;}}
Then ActCache.prepareContext passes normalizeUrlForCacheKey(pageUrl) into buildActCacheKey instead of the raw URL. Tests cover: same URL with reordered params, URL without params, malformed URL fallback.
scope
Files: packages/core/lib/v3/cache/ActCache.ts, packages/core/lib/v3/cache/utils.ts, new test under packages/core/tests/unit/.
One-time effect on existing on-disk caches: keys for URLs that have query params will change. Old entries become unreachable but don't break anything — they just sit until purged. Could ship behind a no-op in a separate PR if that's a concern.
Happy to open the PR right after this — wanted the issue on the books first as a reference.
Activity
fix(core): normalize URLs in ActCache key derivation (#2190)
fix(core): normalize URLs in ActCache key derivation (#2190) (#2233)
fix(core): normalize URLs in ActCache key derivation (browserbase#2190)…