Skip to main content

Module prefetch

Module prefetch 

Source
Expand description

What an HTML document is about to ask for.

This exists because of a limit in the browser, not in the remote. A page with forty subresources is not forty requests made at once: HTTP/1.1 allows six connections per origin, so it is seven waves, each discovered only once the previous one came back. Seven waves is seven remote round trips, and the count grows with the number of subresources — which is exactly what invariant 1 says must not happen.

Reading the page’s own references first collapses that to one batch. The waves then arrive to find everything already held.

The scanner is a heuristic and does not need to be better than one, because it can only affect speed, never correctness. Every subresource is still served by a real request through the real guards: a reference missed here is fetched normally, and a reference invented here is a read that fails and is dropped. Nothing it does can make a page wrong. That is what makes hand-scanning acceptable here when it would not be if the scan decided what a reader is allowed to see.

Constants§

MAX_SUBRESOURCES
How many references to take from one document.

Functions§

scan
Collect the subresources an HTML document refers to, in document order, without repeats.