Navigation activated from a speculation-rules prefetch isn't served from that prefetch's own cache entry
Categories
(Core :: DOM: Networking, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox162 | --- | fixed |
People
(Reporter: smayya, Assigned: smayya)
References
(Blocks 2 open bugs)
Details
(Whiteboard: [necko-triaged])
Attachments
(1 external file, 1 obsolete file)
DocumentLoadListener::TryActivateFromPrefetch serves the activated navigation through a fresh HTTP cache lookup by the navigation's URL. The prefetch record keeps no reference to the cache entry it wrote, so nothing ties the navigation to that entry.
When the URLs differ (No-Vary-Search), the exact key misses and CacheStorageService::AddStorageEntry returns the first No-Vary-Search candidate on the same path, which can be an unrelated response. Since bug 2070841 skips validation for activated navigations, that response (often expired, no-store) is served without revalidation.
Evidence (no-vary-search/prefetch-single.https.html, MOZ_LOG=SpeculationRules:5,cache2:5):
- All variants in one browser, no cache purges: 20 of 22 activated navigations got another test's entry (some executor pages send
No-Vary-Search: params, making the per-testuuidignorable); 9 failed. - Each variant in its own browser: every activated navigation got its own entry and passed.
Expected: an activated navigation is served only from its prefetch record's entry. E.g. keep the entry (nsICachingChannel::GetCacheToken()) on the record in PrefetchRecordParent::OnStopRequest, and skip validation only when the navigation's entry matches it (cacheEntryId). Choosing the record from the navigation's source document is tracked in bug 2076693. Clearing a document's cache entries on navigate-away (planned under this meta) reduces leftovers but doesn't replace this check.
To be investigated later: with default prefs the prefetched no-store entry (expiration time 0) is sometimes removed by MemoryPool::PurgeExpiredOrOverMemoryLimit before the navigation, so it misses and goes to the network. This also explains CI failures in tests that navigate to the exact prefetched URL (bug 2076682).
| Assignee | ||
Comment 1•1 month ago
|
||
Another case: speculation-rules/prefetch/navigation-timing-delivery-type.https.html?prefetch=true&bypass_cache=true failed on try (test-linux2404-64/opt-web-platform-tests-2):
https://treeherder.mozilla.org/logviewer?job_id=597434682&repo=try&task=GUxerI2oQdmm3UKu_yFBUw.0&lineNumber=7135
TEST-UNEXPECTED-FAIL … assert_in_array: Prefetch https://web-platform.test:8443/speculation-rules/prefetch/resources/executor.sub.html?… should work. The navigated page had no Sec-Purpose: prefetch. On try it ran right after ?prefetch=true&bypass_cache=false and ?prefetch=false&bypass_cache=true in the same browser. Reordering the variants locally reproduces it.
Root cause: the prefetch is served from an existing HTTP cache entry instead of being fetched for the prefetch, so the record doesn't end up with its own response. This is the prefetch-side counterpart of comment 0. Tying cache entries to the prefetch record and the document that initiated it should cover both directions:
- the prefetch shouldn't reuse an entry that wasn't fetched for it
- the activated navigation should only be served from the record's own entry
Marked expected: [PASS, FAIL] with this bug for now.
| Assignee | ||
Updated•1 month ago
|
| Assignee | ||
Comment 2•1 month ago
|
||
The prefetched response lives in the HTTP cache, but nothing referenced its
entry once the prefetch channel finished, so the cache could purge it before
the navigation used it (an expired no-store response is purged as soon as a
purge runs). Hold the entry in the prefetch record until the record is
canceled or destroyed.
| Assignee | ||
Comment 3•1 month ago
|
||
Looking up the navigation URL in the HTTP cache can return a different
No-Vary-Search-equivalent entry than the one the prefetch stored. Open the
entry the prefetch record holds instead, read-only, so the navigation gets the
record's response as the spec requires. Records reached through redirects keep
the existing lookup for now.
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
Updated•25 days ago
|
Comment 7•23 days ago
|
||
| bugherder | ||
Updated•4 days ago
|
Description
•