From 850acf7dddf7edd235377e5a37faa00f42ab0c9b Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Mon, 29 Oct 2018 07:33:31 -0700 Subject: [PATCH] Update caching.md (#9482) --- docs/docs/caching.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/docs/caching.md b/docs/docs/caching.md index 0c4b02f4a1022..b77592aa47765 100644 --- a/docs/docs/caching.md +++ b/docs/docs/caching.md @@ -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/)