-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Server, Streamer] HTTP header rel=prefetch Links, prioritized media-types? #97
Comments
Example implementation: Priority list:
As soon as the number of HTTP prefetch links reaches the maximum ceiling limit (default is 10), the remainder of the prioritized list of prefetch-able resources is ignored. For example, if there are many CSS and JS files, fonts may not be prefetched at all. |
A few quick notes off the top of my head, as I’d be expecting this to primarily impact fixed-layout EPUB in the near future.
|
In an ideal world, we would know for each HTML resource which CSS, JS and fonts is used. This would enable us to trigger the prefetch strictly when each HTML resource is requested. While we could eventually achieve that with some heavy processing, we need something "less than ideal" in the meantime. Here's my take on this:
Prefetching through HTML links won't be affected by the same limitations as the |
Well, I guess CSS should be highest, given it’s render/layout-blocking, independently of the rendition (e.g. reflow/pre-paginated). Fonts are critical for fixed-layout EPUB. Otherwise, browsers have defined they are not a long time ago (cf. font-display CSS prop). That said, you can’t necessarily swap or make them optional in EPUB reflow for example, because of fragmentation/pagination. Scripts, I don’t have enough insights/data/anecdotes. Personally, I’ve always put them at the end of the However, I guess adjusting the prioritization in this doc could be a good start: https://docs.google.com/document/d/1bCDuq9H1ih9iNjgzyAL0gpwNFiEP4TZS-YLRp_RuMlc/edit# Especially as it can also serve as a ref longer term, for heuristics. It seems CSS always win over fonts and JS, cf. default priorities section there: https://developers.google.com/web/fundamentals/performance/resource-prioritization Note however there’s now priority hints because “so this script is async but it’s also important” so it kinda is a can of worms. |
Also
I guess it means the server should sent an "Accept-Ranges: bytes" response header in case the user clicks on a link while something is being prefetched? |
We found a quirk with the r2 streamer + AWS load balancer today that is relevant to this. We are running the streamer behind an AWS ALB to create manifest.json on ingestion. That works fine, but we have a tiny fraction of ebooks failing with the not so informative HTTP 502 code. What we discovered is that some books with many CSS files caused the pre fetch headers to pass AWS ALB hard limitation on header size (https://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/how-elastic-load-balancing-works.html). And then all it does is return a 502 with no real message on why this happened. For anyone needing this to run safely on AWS, I guess some kind of size limit configuration would be useful. (In our use case pre-fetching has no value, so we will just disable it. But if anyone else are using the streamer on AWS it is something to be aware of.) |
Thank you @stadskle very useful feedback :) |
Note that since version |
Given the necessity to introduce limits in the number of HTTP header rel=prefetch Links (due to server/client limitations in the total number of bytes supported in HTTP headers), should CSS be prioritized over JS over fonts? (which order?)
Right now, the
r2-streamer-js
implementation generates prefetch Link for these HTTP Content-Types / media types:...however, there is no prioritization heuristic (JSON document order is used to walk the
resources
array property of the ReadiumWebPubManifest). Such prioritization algorithm is trivial to implement, so this is not a technical problem, just an important design consideration now that there is an artificial limit in place.Relevant code diffs:
readium/r2-streamer-js@v1.0.10...v1.0.11
readium/r2-streamer-js@v1.0.11...v1.0.12
Related issue: #96
The text was updated successfully, but these errors were encountered: