Skip to content

core: match scripts to network requests using frameId#16774

Merged
paulirish merged 3 commits into
mainfrom
netreqcache
Jun 5, 2026
Merged

core: match scripts to network requests using frameId#16774
paulirish merged 3 commits into
mainfrom
netreqcache

Conversation

@paulirish

@paulirish paulirish commented Oct 22, 2025

Copy link
Copy Markdown
Member

Fixes a reporting issue in byte-efficiency audits (such as "Remove unused JavaScript") where cached duplicate script requests were reported with full network transfer sizes.

Impact

When a script is loaded in the main frame (network transfer) and subsequently in an iframe (cache hit), Lighthouse reported both instances with the transfer size of the first network load. This inflated the estimated network savings. With this change, cached duplicate loads are correctly mapped to their cache-hit network requests (transfer size of 0), preventing inflated savings.

aka we wont report wasted bytes on cached reqs

Technical Details

  • Mapping Logic: Updated getRequestForScript to match network records using both URL and frameId (extracted from script.executionContextAuxData.frameId). Falls back to URL-only matching if frameId is not present or unmatched.
  • Testing: Added unit tests covering URL matching, redirect destination tracing, frame-based matching, and fallback behavior.

Fixes b/446165500.

@paulirish paulirish requested a review from a team as a code owner October 22, 2025 22:28
@paulirish paulirish requested review from connorjclark and removed request for a team October 22, 2025 22:28
@connorjclark

Copy link
Copy Markdown
Collaborator

don't have context for this - @paulirish still want?

@connorjclark connorjclark changed the title audit(network-requests): expose cache core(network-requests): expose cache in audit details Jun 2, 2026
@connorjclark connorjclark changed the title core(network-requests): expose cache in audit details core(network-requests): add cache property to audit details Jun 2, 2026

@connorjclark connorjclark left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems good. need a better PR commit title though. The change to the audit is the least interesting part of this PR imo, the change to the network lookup seems more impactful.

@paulirish paulirish changed the title core(network-requests): add cache property to audit details core(network-requests): dont report wasted bytes on cached reqs Jun 5, 2026
@paulirish paulirish changed the title core(network-requests): dont report wasted bytes on cached reqs core: match scripts to network requests using frameId Jun 5, 2026
@paulirish paulirish merged commit 3a52f71 into main Jun 5, 2026
36 checks passed
@paulirish paulirish deleted the netreqcache branch June 5, 2026 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants