|
16 | 16 | "headers": [ |
17 | 17 | { |
18 | 18 | "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. |
19 | 21 | "value": "no-cache" |
20 | 22 | } |
21 | 23 | ] |
22 | 24 | }, |
23 | | - { |
24 | | - "source": "/assets/versions.json", |
25 | | - "headers": [ |
26 | | - { |
27 | | - "key": "Access-Control-Allow-Origin", |
28 | | - "value": "*" |
29 | | - } |
30 | | - ] |
31 | | - }, |
32 | 25 | { |
33 | 26 | "source": "/**(*.@(css|js|json|html|svg))", |
34 | 27 | "headers": [ |
|
60 | 53 | "headers": [ |
61 | 54 | { |
62 | 55 | "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. |
64 | 74 | } |
65 | 75 | ] |
66 | 76 | }, |
67 | 77 | { |
68 | | - "source": "/*.svg", |
| 78 | + "source": "/assets/stack-blitz/**", |
69 | 79 | "headers": [ |
70 | 80 | { |
71 | 81 | "key": "Cache-Control", |
72 | | - "value": "public, max-age=31536000" |
| 82 | + // StackBlitz assets are not hashed and should not be cached. |
| 83 | + "value": "no-cache" |
73 | 84 | } |
74 | 85 | ] |
75 | 86 | }, |
76 | 87 | { |
77 | | - "source": "/*.@(webmanifest|ico)", |
| 88 | + "source": "/*.ico", |
78 | 89 | "headers": [ |
79 | 90 | { |
80 | 91 | "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. |
82 | 94 | } |
83 | 95 | ] |
84 | 96 | }, |
|
87 | 99 | "headers": [ |
88 | 100 | { |
89 | 101 | "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. |
91 | 104 | } |
92 | 105 | ] |
93 | 106 | } |
94 | 107 | ], |
95 | | - "ignore": [ |
96 | | - "firebase.json", |
97 | | - "**/node_modules/**", |
98 | | - "tmp", |
99 | | - "deploy" |
100 | | - ] |
| 108 | + "ignore": ["firebase.json", "**/node_modules/**", "tmp", "deploy"] |
101 | 109 | }, |
102 | 110 | "emulators": { |
103 | 111 | "hosting": { |
|
0 commit comments