gatsbyjs / gatsby-docker

Docker image that builds and hosts a Gatsby site
MIT License
356 stars 88 forks source link

About cache control #31

Closed kejiweixun closed 4 years ago

kejiweixun commented 4 years ago

Hi, I have some questions about the default cache control.

The default en variables indicat that all js files will be cached public and expire 1 year. But gatsby doc suggest sw.js shoud be uncachable:

The only exception to this is the file /sw.js, which needs to be revalidated upon each load to check if a new version of the site is available. This file is generated by gatsby-plugin-offline and other service worker plugins, in order to serve content offline. Its cache-control header should be cache-control: public, max-age=0, must-revalidate1

And the doc also says json files should be uncachable too:

Similar to HTML files, the JSON files in the public/page-data/ directory should never be cached by the browser.

How can I achieve this? I try the following, but didn't work: - CACHE_IGNORE=html|page-data\.json|sw\.js - CACHE_IGNORE=html|page-data.json|sw.js

If just use json, the json files work, but how to specify sw.js? - CACHE_IGNORE=html|json|sw.js

Thanks!

kejiweixun commented 4 years ago

After looking into the nginx-boot.sh file, I think it has to take the append rule approach