Open janwerkhoven opened 5 years ago
@janwerkhoven this looks awesome. But this project hasn't had any love in 8 months and I've never gotten a response on any PR in over a year. Maybe fork it?
@mhluska Thanks, I'd love to contribute.
I think I first will have to learn more about Node, Express and Fastboot internals though... 😅
Was hoping someone with experience would point in the right direction.
This would be sweeeeeeet.
I believe Fastboot could be serving assets even faster if it were leverage HTTP/2 sever push.
Background
Server push, which is defined in the HTTP/2 specification, allows a server to pre‑emptively push resources to a remote client, anticipating that the client may soon request those resources.
That's perfect for an Ember app because we always have 4 predictable files that need to be loaded:
ember-app.js
ember-app.css
vendor.js
vendor.css
The idea
The idea is to push these 4 files along with the
index.html
to the client instead of waiting forindex.html
to land, then fire 4 request, then wait for those requests to land.Nginx
In Nginx you can specify files to push with
http2_push
:Pre-emptively pushing these files increase my project's load times from:
To:
Before:
After:
That's amazing! 🌮
Do give me more! 🙏
Caveat
The Ember files are fingerprinted... Which is great for busting caches when deploying new fixes, but that also breaks having set static
http2_push
paths.Bad solution
Stop fingerprinting files in order to leverage static
http2_push
. 🔥Is bad because busting caches is arguably more important.
Beter solution
Since NGINX 1.13.9 support was
http2_push_preload on;
which automatically HTTP/2 server pushes files marked by theLink
header.That means in Nginx setting:
And having Fastboot somehow add the following response header when fetching
index.html
:Would preload this JS and CSS file.
Feature request?
Is there a way to add the
Link
header to each Fastboot responses?Does Fastboot have an index of the fingerprinted files we can concatenate into the
Link
header?