Open Bug 859177 Opened 11 years ago Updated 4 years ago

Investigate link rel=subresource prefetching

Categories

(Core :: Networking, enhancement, P5)

enhancement

Tracking

()

People

(Reporter: greg, Unassigned)

References

Details

(Whiteboard: [necko-backlog])

Use case: prefetcher can start loading a file before javascript parse/execute and XHR send.

Note - this is different that prefetch, as it applies to resources within the currently loading page, not a future navigation.

<link rel="subresource" href="blah.json" />

<script>
   var req = new XMLHttpRequest();
   req.onload = function() {
      console.log(this.responseText);
   };
   req.open("get", "blah.json", true);
</script>

See chromium docs:
http://www.chromium.org/spdy/link-headers-and-server-hint/link-rel-subresource

Not sure about standards discussion.
Patrick, is that even a useful operation with our current network stack?  Last I checked if the prefetch were not done by the time open() is called, the open() would just end up doing a new request...
bz, this would take some hacking but its an interesting use case :)

I think we'd have to change the channel to block on an in-progress cache entry with the assumption that the result will be cacheable in the case this subresource link syntax was used.

I have seen js that does a whole bunch of XHRs off onPageLoad to essentially load the cache for reuse by other script functions.. its basically an automation of that.

Honestly, this reminds me a lot of spdy push.. which has a similar mechanism in that it moves resources before they are referenced by the dom. (in that case there isn't an official markup syntax for it.. the server is in charge of omnisciently knowing, but adding markup would be one way to implement that.. ala server side includes but with better cachability.)
Do not forget that this is also available via the HTTP header (tbh, that's where I expect it will be most useful), e.g:

Link: </styles.min.css>;rel="stylesheet subresource"

[Though perhaps for a non-alternative stylesheet, rel=subresource may not even be necessary, since the link will have a high priority anyway.]
Honza, is this something for Bug 941841? :)

My use case would be lazy-loading of (cross-origin) webfonts to not slow down rendering in bad networks. Subresource prefetching should allow having a shorter (or no) FOUC were network conditions are good.
Status: UNCONFIRMED → NEW
Component: General → Networking: Cache
Ever confirmed: true
Flags: needinfo?(honzab.moz)
Not sure this is related to cache at all.

What's FOUC ?
Flags: needinfo?(honzab.moz)
Flash of unstyled content (in this case: wrong font).

(In reply to Honza Bambas (:mayhemer) from comment #5)
> Not sure this is related to cache at all.

The new cache includes new prefetching (and some prioritized loading) logic, doesn't it? And this bug is essentially about a prefetching mechanism. Or was that simply about the database stuff, and actual prefetching is handled by another component (e.g. the preloader – which category should this bug be in, then)?
(In reply to Florian Bender from comment #6)
> Flash of unstyled content (in this case: wrong font).
> 
> (In reply to Honza Bambas (:mayhemer) from comment #5)
> > Not sure this is related to cache at all.
> 
> The new cache includes new prefetching (and some prioritized loading) logic,
> doesn't it? 

It can load some files from disk sooner then others despite order of AsyncOpenURI calls for them.  But that is all controlled by the consumer, cache itself just dumbly listens to commands from above.

> And this bug is essentially about a prefetching mechanism. Or
> was that simply about the database stuff, and actual prefetching is handled
> by another component (e.g. the preloader – which category should this bug be
> in, then)?

Hmm.. hard to say.  Does the preloader already exists?  Is that something around Nick's Network Seer?

I personally wanted to make the new cache smarter like doing preloads and offer prefetch/preconnect data directly, but the new cache work was already enough complicated that I moved the work and even planning to some future point.  And then Nick wrote his Seer.
Ah, yes, Seer is probably a better match here.
Component: Networking: Cache → Networking
I'd say WONTFIX since Chrome removes <link rel=subresource> just now?

https://crbug.com/581840
btw, replacement should be <link rel=preload>, bug 1222633
Whiteboard: [necko-backlog]
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: -- → P1
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: P1 → P3

Bulk-downgrade of unassigned, >=3 years untouched DOM/Storage bug's priority.

If you have reason to believe this is wrong, please write a comment and ni :jstutte.

Severity: normal → S4
Priority: P3 → P5

This bug is obsolete and should be closed. Chromium (Chrome 50) removed support:

"Remove support for the "subresource" rel of HTMLLinkElement, as it is not useful, proprietary, and buggy. "
https://www.chromestatus.com/feature/6596598008119296

You need to log in before you can comment on or make changes to this bug.