Skip to content

[gatsby] gatsby serve cache paramaters #31510

@moonmeister

Description

@moonmeister

Description

For anyone using gatsby serve cache headers are not being set correctly.

Steps to reproduce

  1. using any Gatsby site
  2. gatsby build
  3. gatsby serve
  4. Open dev tools network tab and check the response headers for all requested files at. localhost:9000

Expected result

I'd expect Gatsby's provided server implementation to follow best practices.
https://www.gatsbyjs.com/docs/caching/

Actual result

Gatsby serve appears to set cache headers as public, max-age=0 for all files which is wrong according to https://www.gatsbyjs.com/docs/caching/.

Environment


  System:
    OS: macOS 10.15.7
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.17.0 - ~/.nvm/versions/node/v14.17.0/bin/node
    Yarn: 1.22.10 - ~/.nvm/versions/node/v14.17.0/bin/yarn
    npm: 6.14.13 - ~/.nvm/versions/node/v14.17.0/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 90.0.4430.212
    Firefox: 88.0.1
    Safari: 14.1
  npmPackages:
    gatsby: ^3.4.1 => 3.5.1 
    gatsby-plugin-image: ^1.5.0 => 1.5.0 
    gatsby-plugin-manifest: ^3.5.0 => 3.5.0 
    gatsby-plugin-postcss: ^4.5.0 => 4.5.0 
    gatsby-plugin-react-helmet: ^4.5.0 => 4.5.0 
    gatsby-plugin-sharp: ^3.5.0 => 3.5.0 
    gatsby-plugin-sitemap: ^4.1.0 => 4.1.0 
    gatsby-source-filesystem: ^3.5.0 => 3.5.0 
    gatsby-source-wordpress: ^5.5.1 => 5.5.1 
    gatsby-transformer-sharp: ^3.5.0 => 3.5.0 

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: DXDeveloper Experience (e.g. Fast Refresh, i18n, SSR, page creation, starters)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions