Open Dreamsorcerer opened 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).
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.
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.