Help serving assets over HTTP/2 for a Gatsby Netlify hosted site

— 2 minute read

Boost on DEV

Photo by Lukas Juhas on Unsplash

Hi all. I threw out this Tweet into the Twitterverse, but thought it would be wise to ask for help here as well.

I have a Gatsby site deployed to Netlify, and some of my assets are being served over HTTP/1.1. I know that Netlify supports HTTP/2 by default for sites enabled with HTTP2.

I know that I need to add entries into my _headers file, e.g.

  Link: </js/example-script.js>; rel=preload; as=script
  Link: </css/example-style.css>; rel=preload; as=style

but it would be a pain to update this after every deploy. Is anyone aware of a gatsby plugin that might do this, or how do you go about handling this with your Gatsby site when hosted on Netlify?

I can probably generate the _headers file as part of my build process, but my gut tells me someone has already done this 😉

The source code is here if anyone is interested.

Comment on DEV