Skip to content

Commit

Permalink
Update caching.md (#9482)
Browse files Browse the repository at this point in the history
<!--
  Q. Which branch should I use for my pull request?
  A. Use `master` branch (probably).

  Q. Which branch if my change is a bug fix for Gatsby v1?
  A. In this case, you should use the `v1` branch

  Q. Which branch if I'm still not sure?
  A. Use `master` branch. Ask in the PR if you're not sure and a Gatsby maintainer will be happy to help :)

  Note: We will only accept bug fixes for Gatsby v1. New features should be added to Gatsby v2.

  Learn more about contributing: https://www.gatsbyjs.org/docs/how-to-contribute/
-->
  • Loading branch information
KyleAMathews authored and DSchau committed Oct 29, 2018
1 parent 553ad80 commit 850acf7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions docs/docs/caching.md
Expand Up @@ -18,12 +18,16 @@ All files in `public/static/` should be cached forever. For files in this direct

The `cache-control` header should be `cache-control: public,max-age=31536000,immutable`

## JavaScript
## JavaScript and CSS

Other files e.g. JavaScript files should also be cached forever. This is because webpack 4 now also generates hashes for all files based on the content of the files, similar to what webpack 1 used to do with static files (see above).
JavaScript and CSS files _generated by webpack_ should also be cached forever. Like static files, Gatsby creates JS & CSS file names (as a hash!) based on the file content. If the file content is changed, the file hash will change, therefore these files _generated by webpack_ are safe to cache.

The `cache-control` header should be `cache-control: public, max-age=31536000,immutable`

How you calibrate your caching depends on how you're hosting your site. We encourage people to create Gatsby plugins which automate the creation of caching headers for Gatsby sites. The following plugins have been created:
## Setting up caching on different hosts

How you setup your caching depends on how you host your site. We encourage people to create Gatsby plugins per host to automate the creation of caching headers.

The following plugins have been created:

- [gatsby-plugin-netlify](/packages/gatsby-plugin-netlify/)

0 comments on commit 850acf7

Please sign in to comment.