Why a Preload URL Can Miss the Asset Your Page Actually Requests

Troubleshoot a preload URL that does not match the requested resource. Compare URLs, request attributes, redirects, and cache behavior in your browser.

Published
Reading time
7 min read
Why a Preload URL Can Miss the Asset Your Page Actually Requests
On this page

A preload can download a resource without helping the element that needs it. A different path, origin, or query string can make the later request a different URL; incompatible request attributes can also prevent reuse even when the URL looks identical.

This guide shows how to compare the two requests in a browser’s Network panel and how to decide whether the preload is worth keeping.

Key Takeaways

  • Compare the complete resolved URL, including scheme, host, port, path, and query string—not just the filename.
  • Match the preload’s resource destination, set with as, and its cross-origin settings to the eventual request.
  • Redirects, content negotiation, and caching can complicate what appears in the Network panel. A single visible request alone does not prove that the preload was reused.
  • Remove a preload if the resource is already discovered early or is not important to the initial page experience.

What needs to match?

A preload tells the browser about a resource before it would otherwise discover it. For the later consumer to benefit, it must request a compatible resource. Start with these checks:

CheckExample mismatchWhat to inspect
Resolved URL/images/hero.svg versus /assets/hero.svgFull request URL, not the URL as written in markup
Originhttps://www.example.test/app.css versus https://cdn.example.test/app.cssScheme, host, and port
Query string/hero.svg?v=1 versus /hero.svg?v=2Parameter names, values, and ordering
Destinationas="fetch" for a resource later used as an imageThe preload’s as value and the consuming element or API
Cross-origin settingsA font preload without crossoriginThe preload and consumer’s request mode and credentials behavior

Relative URLs are resolved against the document’s base URL. A <base> element, a stylesheet’s location, or build tooling can therefore make two similar-looking references resolve differently. Compare what the browser actually requested.

Query parameters often carry version identifiers, transformation options, or signatures. Do not remove or reorder them merely to make strings look alike: the server may treat the resulting URL differently.

Advertisement

Reproduce a URL mismatch in the Network panel

The following local example deliberately preloads one query-string version of an image and displays another. It requires Python 3 and a browser with developer tools. The code has not been executed for this article.

Create a directory containing these two files:

index.html

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Preload comparison</title>
  <link rel="preload" as="image" href="/hero.svg?v=1">
</head>
<body>
  <h1>Preload comparison</h1>
  <img src="/hero.svg?v=2" alt="Blue square" width="120" height="120">
</body>
</html>

hero.svg

<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120">
  <rect width="120" height="120" fill="royalblue"/>
</svg>

From that directory, start a local server:

python3 -m http.server 8000

Open http://localhost:8000/ and use the browser’s developer tools:

  1. Open the Network panel before reloading. Enable preservation of the request log if your browser provides it.
  2. Reload the page and filter the requests for hero.svg. Select each matching entry and inspect its full request URL, request headers, initiator or cause, and timing information where available.
  3. Compare v=1 with v=2. The two references resolve to different URLs, even though this local server may return the same file contents for both.
  4. Change the preload’s href to /hero.svg?v=2, save the file, and reload. Inspect the request list and initiator information again. The markup now describes the same image URL and destination; this is a better candidate for preload reuse, not a guarantee that a particular browser will schedule or display it in a specific way.
  5. If results are unclear, repeat with a fresh browser session or cleared site cache. If you use a Disable cache option, note that it changes the conditions being investigated. Stop the server with Ctrl+C when finished.

Browser interfaces and preload behavior can differ by version. The HTML Living Standard and current documentation for a particular browser were not available to consult for this article; check the documentation for your browser and version when interpreting its request details or warnings.

When the panel shows only one request

One network entry can be consistent with successful reuse, but it is not conclusive by itself. The resource might already be cached, an in-flight request might be shared, or the browser might not have issued the preload. Inspect initiator and cache information, then compare controlled reloads. Conversely, repeated-looking entries can include redirects or cache-related activity rather than two independent body downloads.

Check request attributes and server behavior

Destination and cross-origin settings

Set as to the kind of resource the eventual consumer needs, such as image, style, script, or font. A correct URL with an incompatible destination may not satisfy the later request.

Fonts are a common cross-origin-settings trap. For example, a font preload typically needs crossorigin even when the font URL is on the same origin, because the preload needs to be compatible with the font request:

<link rel="preload" href="/fonts/body.woff2" as="font"
      type="font/woff2" crossorigin>

For cross-origin assets, compare the consumer’s request mode and credentials behavior with the preload’s settings. The remote server must also permit the relevant cross-origin request when CORS is required. Simply adding crossorigin everywhere can change a request and introduce a mismatch or a CORS failure; match it to the actual consumer instead.

The type and media attributes can affect whether a browser considers a preload applicable. Check them if a hint is present in the HTML but no corresponding preload request appears.

Redirects

Inspect the redirect chain as well as the final response URL. A preload pointing at a redirecting URL and a consumer pointing directly at its destination are different starting references; do not assume that arriving at the same final URL guarantees reuse. Redirect policies and browser caching can also affect what appears in the panel. When practical, use the same stable URL in both references and verify the behavior in the target browser.

Content negotiation and caches

A server can return different representations for a URL based on request headers. Compare relevant request and response headers, including Accept and Vary, when investigating unexpected representations or cache behavior. A shared URL does not by itself prove that the server returned the same representation under every request condition.

HTTP caches, the browser’s in-memory state, service workers, and cache directives can all affect whether another network transfer is visible. A cache hit does not necessarily mean the preload was matched, and a reload with the cache disabled does not represent every real visit. Test the conditions relevant to your application, including a fresh visit and a repeat visit where appropriate.

Advertisement

When a preload may be unnecessary

Preloading is most useful when an important resource would otherwise be discovered late—for example, an image referenced by a stylesheet that is itself loaded later. If the resource is already near the start of the HTML and discovered promptly, the hint may add little value.

Avoid preloading every asset. An unused hint can consume bandwidth and compete with resources the page actually needs. Compare page behavior with and without the hint using the same test conditions, and keep it only when it solves a demonstrated loading problem. Also check that responsive or conditional resources are not preloaded for visitors who will never use them.

Common Mistakes

  • Comparing only filenames while ignoring the origin, path, query string, or resolved base URL.
  • Assuming that the same final URL after redirects proves the preload was reused.
  • Treating as, CORS settings, or a browser warning as irrelevant because the URL strings match.
  • Declaring success from a single Network entry without considering cache state or request initiation.
  • Preloading a resource that is conditional, unused, or already discovered early.

Best Practices

  • Generate the preload and consuming reference from the same asset manifest or configuration when possible, especially for fingerprinted filenames and CDN URLs.
  • Compare full request URLs and relevant attributes in the browser actually used by your audience.
  • Investigate redirect chains, response headers, service workers, and cache state before concluding that a second transfer occurred.
  • Avoid copying sensitive query strings or cookies from developer tools into tickets or public examples.

Conclusion

Start with the resolved URLs, then check destination, cross-origin settings, redirects, and cache state. A preload is useful only when it helps the later consumer under the conditions that matter to your page.

What would your domain sell for?

A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.