Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit c80c353

Browse files
committed
Rework caching header rules in an attempt to fix caching issues
1 parent 72451b3 commit c80c353

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

firebase.json

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,12 @@
1616
"headers": [
1717
{
1818
"key": "Cache-Control",
19+
// The `index.html` file (or when loaded as SPA), should never be cached. Older
20+
// JavaScript sources and assets would be loaded that might no longer be available.
1921
"value": "no-cache"
2022
}
2123
]
2224
},
23-
{
24-
"source": "/assets/versions.json",
25-
"headers": [
26-
{
27-
"key": "Access-Control-Allow-Origin",
28-
"value": "*"
29-
}
30-
]
31-
},
3225
{
3326
"source": "/**(*.@(css|js|json|html|svg))",
3427
"headers": [
@@ -60,25 +53,44 @@
6053
"headers": [
6154
{
6255
"key": "Cache-Control",
63-
"value": "public, max-age=15811200, s-maxage=31536000"
56+
// Images and SVGs are not hashed but are also expected to change rarely.
57+
// There are a lot of SVGs in our docs app, and we want to cache them longer.
58+
"value": "public, max-age=8640000" // 100 days.
59+
}
60+
]
61+
},
62+
{
63+
"source": "/assets/versions.json",
64+
"headers": [
65+
{
66+
"key": "Access-Control-Allow-Origin",
67+
"value": "*"
68+
},
69+
{
70+
"key": "Cache-Control",
71+
// The versions file should not be cached for too long since we are
72+
// deploying on a weekly basis and this file is rather small.
73+
"value": "public, max-age=604800" // 7 days.
6474
}
6575
]
6676
},
6777
{
68-
"source": "/*.svg",
78+
"source": "/assets/stack-blitz/**",
6979
"headers": [
7080
{
7181
"key": "Cache-Control",
72-
"value": "public, max-age=31536000"
82+
// StackBlitz assets are not hashed and should not be cached.
83+
"value": "no-cache"
7384
}
7485
]
7586
},
7687
{
77-
"source": "/*.@(webmanifest|ico)",
88+
"source": "/*.ico",
7889
"headers": [
7990
{
8091
"key": "Cache-Control",
81-
"value": "public, max-age=604800, s-maxage=1209600"
92+
// Icons and the favicon are expected to change rarely. We cache it, but not for too long.
93+
"value": "public, max-age=2592000" // 30 days.
8294
}
8395
]
8496
},
@@ -87,17 +99,13 @@
8799
"headers": [
88100
{
89101
"key": "Cache-Control",
90-
"value": "public, max-age=31536000"
102+
// JS ans CSS files are hashed and can be cached indefinitely.
103+
"value": "public, max-age=31536000" // 365 days.
91104
}
92105
]
93106
}
94107
],
95-
"ignore": [
96-
"firebase.json",
97-
"**/node_modules/**",
98-
"tmp",
99-
"deploy"
100-
]
108+
"ignore": ["firebase.json", "**/node_modules/**", "tmp", "deploy"]
101109
},
102110
"emulators": {
103111
"hosting": {

0 commit comments

Comments
 (0)