Skip to content

Commit 0535fd5

Browse files
committed
added caching
1 parent ebb9cdd commit 0535fd5

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

scripts/webpack.client.config.js

+30-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,36 @@ module.exports = (options = {}) => merge(
6767
]
6868
}),
6969
].concat(prod ? [
70-
new GenerateSW(),
70+
new GenerateSW({
71+
runtimeCaching: [{
72+
urlPattern: "",
73+
handler: 'StaleWhileRevalidate',
74+
options: {
75+
cacheName: 'code-server',
76+
expiration: {
77+
maxAgeSeconds: 86400,
78+
},
79+
cacheableResponse: {
80+
statuses: [0, 200],
81+
},
82+
},
83+
}
84+
// Network first caching is also possible.
85+
/*{
86+
urlPattern: "",
87+
handler: 'NetworkFirst',
88+
options: {
89+
networkTimeoutSeconds: 4,
90+
cacheName: 'code-server',
91+
expiration: {
92+
maxAgeSeconds: 86400,
93+
},
94+
cacheableResponse: {
95+
statuses: [0, 200],
96+
},
97+
},
98+
}*/]
99+
}),
71100
] : [
72101
new webpack.HotModuleReplacementPlugin(),
73102
]),

0 commit comments

Comments
 (0)