HTTP/2 Server Push Before Initial Response?


I have a site behind Cloudflare with which I’d like to use HTTP/2 Server Push. The site has to do some slower processing before determining the HTTP status code and headers, so I’d like to push before the initial request’s response.

The timeline would look something like this:

  1. Client requests index.html
  2. Server sends PUSH_PROMISES for script.js , styles.css , and font.woff2
  3. Server sends HTTP headers and data for the assets above
  4. Server does some heavy processing to determine index.html response…
  5. Server sends HTTP headers and data for index.html

Is this possible with Cloudflare, or can I only use HTTP/2 Push via the Link header? Based on my understanding of HTTP/2 Server Push without the Link header?, this does not seem possible with Cloudflare.

Could I use a Cloudflare Worker to preemptively initiate a Server Push? Even if this is possible, it feels wrong because my site is what knows which static assets should be Pushed. The Worker would need some way of figuring out which assets to push.

You should probably edit your original post to move it to category Developers > Workers, which is more likely to be monitored by the workers ninjas out there.

1 Like

Thanks! I noticed there’s an HTTP/2 Server Push Worker Template, but it’s also using the Link header.

I haven’t found a way to initiate a Server Push through Cloudflare any other way.

This topic was automatically closed after 30 days. New replies are no longer allowed.