Skip to content

Commit

Permalink
docs(deploying-to-firebase.md): add firebase.json cache configuration (
Browse files Browse the repository at this point in the history
…#21897)

* docs(deploying-to-firebase.md): add firebase.json cache configuration

Adds how to update the `firebase.json` to configure the firebase cache correctly.

* chore: format

Co-authored-by: GatsbyJS Bot <mathews.kyle+gatsbybot@gmail.com>
  • Loading branch information
portenez and GatsbyJS Bot committed Mar 2, 2020
1 parent 1f4db4b commit ae30ba8
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions docs/docs/deploying-to-firebase.md
Expand Up @@ -45,6 +45,64 @@ In this guide, you will learn how to deploy your Gatsby site to Firebase Hosting

When prompted to select your public directory, press <kbd>enter</kbd>. It will default to `public`, which is also Gatsby's default public directory.

1. Update the `firebase.json` with the following cache settings

```json
{
"hosting": {
"public": "public",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"headers": [
{
"source": "**/*",
"headers": [
{
"key": "cache-control",
"value": "cache-control: public, max-age=0, must-revalidate"
}
]
},
{
"source": "static/**",
"headers": [
{
"key": "cache-control",
"value": "public, max-age=31536000, immutable"
}
]
},
{
"source": "**/*.@(css|js)",
"headers": [
{
"key": "cache-control",
"value": "public, max-age=31536000, immutable"
}
]
},
{
"source": "sw.js",
"headers": [
{
"key": "cache-control",
"value": "cache-control: public, max-age=0, must-revalidate"
}
]
},
{
"source": "page-data/**",
"headers": [
{
"key": "cache-control",
"value": "cache-control: public, max-age=0, must-revalidate"
}
]
}
]
}
}
```

1. Prepare your site for deployment by running `gatsby build`. This generates a publishable version of your site in the `public` folder.

1. Deploy your site by running the following command:
Expand Down

0 comments on commit ae30ba8

Please sign in to comment.