We-Amp / ngx_pagespeed

Automatic PageSpeed optimization module for Nginx
http://ngxpagespeed.com/
Apache License 2.0
21 stars 1 forks source link

103 Early Hints #4

Open Dreamsorcerer opened 9 months ago

Dreamsorcerer commented 9 months ago

An idea for a future optimisation would be to use the 103 Early Hints response: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103

Basically, when the page can't be cached, it should try caching the resources linked in the page, in order to send in a 103 response for future requests. It could also try to predict the resources for new requests, e.g. if a resource is sent in all requests or all requests for a common URL prefix.

oschaaf commented 9 months ago

Interesting. This does remind me of this design doc which I think was implemented at to trigger dns prefetching (via the insert_dns_prefetch filter).

Dreamsorcerer commented 9 months ago

Yes, this is basically one stage after that. Cloudflare say they are using machine learning to guess what resources would be needed. It sounds like they only pick out links which are already labelled as prefetch/preload in the origin document, so we could do better here if that design were also implemented.

This can still provide a decent boost without machine learning though, if it's too complex to do.

https://blog.cloudflare.com/early-hints/