Earlier today I was looking at a couple of sites to see why they were much slower than I expected. I ran them through GTmetrix and saw the following in the waterfall tab.
Straightaway I could see that this is the classic pattern produced by trying to load a bunch of assets from a HTTP/1.x only host. HTTP/1.x has a limit on how many connections a browser can make per server. A small number of requests get sent off and then you have to wait until they return before sending more off.
HTTP/2 fixed this by having one connection per server, but multiplexing all the requests over that connection. As a result, it is often much faster than HTTP/1.x.
So you'd expect a CDN would allow this option (most do). I did some research but came across this page where you could vote on the feature being enabled. Seriously?? So I asked DigitalOcean on Twitter what was going on, and they responded.
At this time, HTTP2 is not supported in CDN. Our Engineering Team is working on the feature of HTTP2 to work with CDN. However, We do not have any ETA for the same. Your patience and understanding in this regard will be highly appreciated.— DigitalOcean (@digitalocean) June 7, 2019
Wow. They're running a CDN that doesn't support HTTP/2? Ok, well that's interesting... let's see if we can easily hook it up to Cloudflare and proxy through.
We apologize but proxy via CloudFlare will not work with Spaces.— DigitalOcean (@digitalocean) June 7, 2019
Oh come on. That means that you're stuck with HTTP/1.x if you want to solely to use their infrastructure.
- Enable Cloudflare (or another proxying CDN) and set up
- Point that domain name to your normal web server.
- On your web server, proxy the requests through to your Spaces CDN.
Cloudflare has HTTP/2 on by default, and they do a great job. I really hope DigitalOcean sorts this out soon.
If you'd like someone to help you set this up, email me at email@example.com!