Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.

Generate _headers file #110

Closed
calavera opened this issue Dec 9, 2020 · 0 comments · Fixed by #141
Closed

Generate _headers file #110

calavera opened this issue Dec 9, 2020 · 0 comments · Fixed by #141
Labels
priority: low type: feature code contributing to the implementation of a feature and/or user facing functionality

Comments

@calavera
Copy link

calavera commented Dec 9, 2020

Is your feature request related to a problem? Please describe.

Assets under /_next/static/chunks are always immutable. They can be cached by the browser forever, without having to re-validate their content. Netlify's default cache-control header is not optimal for those assets, however, it can be overriden with a _headers file.

Describe the solution you'd like

Add a new step that generates a _headers file and overrides the cache control for /_next/static/chunks. This can be acomplished with this rule:

/_next/static/chunks/*:
  cache-control: public,max-age=31536000,immutable

See the reference in our docs: https://docs.netlify.com/routing/headers/#syntax-for-the-netlify-configuration-file

Describe alternatives you've considered

We can leave it as it is.

@calavera calavera added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Dec 9, 2020
FinnWoelm added a commit that referenced this issue Dec 15, 2020
The cache control header in netlify dev does not include "public" for
static assets. This is unlike netlify.app. We should probably set
headers in a _headers file as suggested by:
#110

For now, we simply skip the test when running the Cypress tests locally.
FinnWoelm added a commit that referenced this issue Dec 19, 2020
This fixes a failing test when running npm run cypress:local.

The failing test is testing the cache control header of a pre-rendered,
static page and expecting the headers to include "public". This is the
case on netlify.app. However, in netlify dev this cache control header
is not present, causing the test to fail.

For now, we simply skip the test when running the Cypress tests locally
(as we do in default_spec.js). In the long term, we should probably set
headers in a _headers file as suggested by #110.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority: low type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants