Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gatsby-plugin-netlify v2 excludes some link headers #9828

Closed
tbrannam opened this issue Nov 8, 2018 · 5 comments
Closed

gatsby-plugin-netlify v2 excludes some link headers #9828

tbrannam opened this issue Nov 8, 2018 · 5 comments
Labels
stale? Issue that may be closed soon due to the original author not responding any more.

Comments

@tbrannam
Copy link
Contributor

tbrannam commented Nov 8, 2018

Description

Since migrating to Gatsby V2 - it appears that fewer JS files are eligible to be be considered for preloading when generating the _headers file.

Steps to reproduce

Add gatsby-plugin-netlify to gatsby-config, no options are necessary.

Build project and view public/_headers

Compare results of / with the headers in public/index.html

In Gatsby V1 - more JS bundles matched - so fewer v2 JS files are being http2/pushed

Expected result

A higher number of JS bundles should match the Link Header filter.

        <link as="script" rel="preload" href="/1-6b41147d931e1c49c090.js"/>
        <link as="script" rel="preload" href="/component---src-pages-index-js-9b3d4efb1774bd71ce96.js"/>
        <link as="script" rel="preload" href="/app-c4e3b0537e6949a7f629.js"/>
        <link as="script" rel="preload" href="/webpack-runtime-6a1e34ce8603dc702023.js"/>

Actual result

Typically only two javascript files are linked. In Gatsby V2 - I would also suggest that /static/*.json files should also be eligible ( <link rel="preload" href="/static/d/688/path---index-6a9-DFSIFoYuSMh60BvyPO97Ulcr4c.json" as="fetch"/> )

example:

/
  Link: </webpack-runtime-c05d24c23b76e621b476.js>; rel=preload; as=script
  Link: </1-6b41147d931e1c49c090.js>; rel=preload; as=script

Environment


  System:
    OS: macOS High Sierra 10.13.6
    CPU: x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.9.0 - ~/.nvm/versions/node/v10.9.0/bin/node
    Yarn: 1.9.4 - /usr/local/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v10.9.0/bin/npm
  Browsers:
    Chrome: 70.0.3538.77
    Firefox: 62.0
    Safari: 12.0.1
  npmPackages:
    gatsby: ^2.0.31 => 2.0.32 
    gatsby-cli: ^2.4.2 => 2.4.3 
    gatsby-image: ^2.0.13 => 2.0.16 
    gatsby-plugin-google-tagmanager: ^2.0.5 => 2.0.5 
    gatsby-plugin-layout: ^1.0.4 => 1.0.4 
    gatsby-plugin-lodash: ^3.0.1 => 3.0.1 
    gatsby-plugin-manifest: ^2.0.4 => 2.0.5 
    gatsby-plugin-netlify: 2.0.3 => 2.0.3 
    gatsby-plugin-pointer-events: ^1.0.2 => 1.0.2 
    gatsby-plugin-react-helmet: ^3.0.0 => 3.0.0 
    gatsby-plugin-react-svg: ^2.0.0 => 2.0.0 
    gatsby-plugin-sitemap: 1.2.14-12 => 1.2.14-12 
    gatsby-plugin-styled-components: ^3.0.0 => 3.0.0 
    gatsby-source-contentful: ^2.0.2 => 2.0.5 
    gatsby-source-filesystem: ^2.0.1 => 2.0.5 
    gatsby-transformer-remark: ^2.1.6 => 2.1.8 
  npmGlobalPackages:
    gatsby: 2.0.33
@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Jan 29, 2019
@gatsbot
Copy link

gatsbot bot commented Jan 29, 2019

Old issues will be closed after 30 days of inactivity. This issue has been quiet for 20 days and is being marked as stale. Reply here or add the label "not stale" to keep this issue open!

@gatsbot
Copy link

gatsbot bot commented Feb 9, 2019

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

Thanks again for being part of the Gatsby community!

@gatsbot gatsbot bot closed this as completed Feb 9, 2019
@mihaiblaga89
Copy link
Contributor

I'm having the same issue.

In my page html I have this:

    <link as="script" rel="preload" href="/0-7936cad5ae04704bde07.js" />
    <link as="script" rel="preload" href="/1-f20b41a24b2827242784.js" />
    <link as="script" rel="preload" href="/3-4cd3248982b0e751f24d.js" />
    <link as="script" rel="preload" href="/2-3e218f81feb4528506b0.js" />
    <link as="script" rel="preload" href="/webpack-runtime-c468a47d7b6d2d976e68.js" />

In _headers file only have this

Link: </webpack-runtime-c468a47d7b6d2d976e68.js>; rel=preload; as=script
Link: </0-7936cad5ae04704bde07.js>; rel=preload; as=script

pieh pushed a commit that referenced this issue Apr 19, 2019
… to _headers (#12521)

## Description

The issue was that only the first file was taken from each key from webpack.stats.json. Modified it to get all of them and render them accordingly.

## Related Issues

Fixes to #9828
@jcayzac
Copy link

jcayzac commented Jul 10, 2019

I think this should be reopened. The critical CSS in my HTML:

<link as="style" rel="preload" href="/styles.9b011d582aac2f4be01f.css"/>

…also doesn't make it into _headers.

jcayzac added a commit to jcayzac/gatsby that referenced this issue Jul 10, 2019
… breaks HTTP/2 push)

This generates the right markup but the Netlify plugin is still broken
(it filters on .js and prevents any other `<link rel="preload">` from making it
into `_headers`)

See:

- gatsbyjs@981bc8c
- gatsbyjs#12521 Bogus PR adding files to `_headers` (has the filter on `.js`)
- gatsbyjs#9828 gatsby-plugin-netlify v2 excludes some link headers
- `from: jc#3330 static-entry.js` search on Discord.
jcayzac added a commit to jcayzac/gatsby that referenced this issue Jul 10, 2019
This allows injecting critical style without inlining (antipattern in HTTP/2).

```js
// gatsby-browser.js
import(/* webpackPreload: true */ `./src/styles/index.sass`)
```

The above generates a `<link as="style" rel="preload" href="/styles.9b011d582aac2f4be01f.css"/>` tag in
each page's `<head>`.

See:

- gatsbyjs@981bc8c
- gatsbyjs#12521 Bogus PR adding files to `_headers` (has the filter on `.js`)
- gatsbyjs#9828 gatsby-plugin-netlify v2 excludes some link headers
- `from: jc#3330 static-entry.js` search on Discord.

Caveats:

`gatsby-plugin-netlify` doesn't parse `.namedChunkGroups.app.childAssets.preload` in the webpack stats, and simply ignore all assets marked for preloading, so this commit still doesn't enable the expected HTTP/2 behavior on Netlify.
@Madgeniusblink
Copy link

does anyone have a guide on how to do the following: https://www.gatsbyjs.org/docs/caching/ ?
I downloaded the gatsby-plugin-netlify but its not so straight forward to set up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale? Issue that may be closed soon due to the original author not responding any more.
Projects
None yet
Development

No branches or pull requests

5 participants