I'm setting the Link header to preload an XHR request that happens on load.
Link: </images/project_icon.png>; rel=preload; as=image,</db/xhr_stuff>; rel=preload
Chrome 57.0 preloads and uses the /images/project_icon.png
just fine but it preloads /db/xhr_stuff
and then misses the copy it just retrieved and loads it a second time after the DOM completely loads. The request headers are identical except the one later one initiated by the xhr has x-requested-with:XMLHttpRequest
set. The only other difference between the requests is the one initiated by the link header shows up as Type: json
and the second Type: xhr
in the Developer Tools.
According to the docs for XHR request, you just omit the as=
attribute.
What is missing to get a cache hit?