Skip to content

Commit ae30ba8

Browse files
portenezGatsbyJS Bot
and
GatsbyJS Bot
authoredMar 2, 2020
docs(deploying-to-firebase.md): add firebase.json cache configuration (#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>
1 parent 1f4db4b commit ae30ba8

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
 

‎docs/docs/deploying-to-firebase.md

+58
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,64 @@ In this guide, you will learn how to deploy your Gatsby site to Firebase Hosting
4545

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

48+
1. Update the `firebase.json` with the following cache settings
49+
50+
```json
51+
{
52+
"hosting": {
53+
"public": "public",
54+
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
55+
"headers": [
56+
{
57+
"source": "**/*",
58+
"headers": [
59+
{
60+
"key": "cache-control",
61+
"value": "cache-control: public, max-age=0, must-revalidate"
62+
}
63+
]
64+
},
65+
{
66+
"source": "static/**",
67+
"headers": [
68+
{
69+
"key": "cache-control",
70+
"value": "public, max-age=31536000, immutable"
71+
}
72+
]
73+
},
74+
{
75+
"source": "**/*.@(css|js)",
76+
"headers": [
77+
{
78+
"key": "cache-control",
79+
"value": "public, max-age=31536000, immutable"
80+
}
81+
]
82+
},
83+
{
84+
"source": "sw.js",
85+
"headers": [
86+
{
87+
"key": "cache-control",
88+
"value": "cache-control: public, max-age=0, must-revalidate"
89+
}
90+
]
91+
},
92+
{
93+
"source": "page-data/**",
94+
"headers": [
95+
{
96+
"key": "cache-control",
97+
"value": "cache-control: public, max-age=0, must-revalidate"
98+
}
99+
]
100+
}
101+
]
102+
}
103+
}
104+
```
105+
48106
1. Prepare your site for deployment by running `gatsby build`. This generates a publishable version of your site in the `public` folder.
49107

50108
1. Deploy your site by running the following command:

0 commit comments

Comments
 (0)
Please sign in to comment.