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.
nickytonline / www.nickyt.co
Source code for my web site nickyt.co
Welcome
This is the source code for the web site of Nick Taylor built using the Eleventy static site generator. It uses Andy Bell's Hylia template. I've made tweaks to it and will probably make more over time, but just wanted to give Andy a shout out for his awesome template.
Terminal commands
Install the dependencies first
npm install
Serve the site locally in watch mode
npm start
Build a production version of the site
npm run production
Test the production site locally
cd dist
npx serve
Licensing
This project contains two separate licenses:
-
Content License: All blog posts, articles, and other written content in the
src/blog
directory are licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).- You are free to share and adapt this content for any purpose, even commercially, as long as you give appropriate credit.
- To view a copy of…
Photo by Lukas Juhas on Unsplash
Top comments (12)
Hey, signed up just to tell that http2 was not working on my Netlify site.
Turns out it was due to a firewall (Avast -> Web Shield -> Turn off "inspect https requests")
If sites like http2.pro/ tells you http2 works on your site, but both Chrome and FF show https1.1 protocol, I suggest you inspect your site from another computer/network and turn off your computer protections...
This is a really annoying thing if ubiquitous user software like Avast start to prevent website optimizations we work hard to setup...
Thanks for the heads up Sebastien!
So I'm actually on the wrong track. What I mention in the post is to enable HTTP2 Server Push which is an optional thing. The pages should be serving over HTTP2. @easyaspython put me on to the right track, but still not solved.
It should use HTTP 2 by default. It looks like all the requests that are HTTP 1.1 from the iamdeveloper domain are being loaded by a service worker. I reckon that has something to do with it.
Yeah that was what @easyaspython had guessed. So I guess a false reading from lighthouse?
It's apparently a bug with Chrome and Lighthouse.
ServiceWorker serving cache in HTTP/1.1 protocol #11123
Description
I deployed my prodution and staging site on Netlify and I got reports from Lighthouse audits that some my resources are being served in HTTP/1.1 protocol which it shouldn't do that.
I found out later that all of the resurces that being served in HTTP/1.1 are from ServiceWorker. I think there's some issue with
gatsby-plugin-offine
Steps to reproduce
Expected result
ServiceWorker should serve cache in HTTP/2 protocol
Actual result
It served in HTTP/1.1 protocol
Environment
gatsby-config.js
Source
package.json
Source
gatsby-node.js
Source
PS. I will drop repository here github.com/rayriffy/rayriffy-blog
It happens in Firefox as well. I think that bug is probably in that gatsby plugin. I've seen service workers use HTTP 2 for loading content before.
Hi Nick,
I just checked your site I believe you still haven't solve this, I am testing out some stuffs the
_headers
andnetlify.toml
. Will report back if that works!Did you ever figure this out?
Ignore me, I just spotted that lighthouse is due to be updated to solve this after mid-April
gatsbyjs.org/packages/gatsby-plugi... also exists
I use Netlify CMS with Gatsby. I believe that includes the
gatsby-plugin-netlify
package? Either way, I guess I just need to configure it as per the docs?