Skip to content

Commit e05c0c5

Browse files
committed
[C] Add cache-control headers to static assets
1 parent 954eb84 commit e05c0c5

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

client/src/servers/common/ProxyHelper.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,23 @@ class ProxyHelper {
3030
this.defineStaticProxy(
3131
app,
3232
"/browser.config.js",
33-
`${this.wwwTarget}/browser.config.js`
33+
`${this.wwwTarget}/browser.config.js`,
34+
{ maxAge: "1h" }
3435
);
35-
this.defineStaticProxy(app, "/build", `${this.wwwTarget}/build`);
36-
this.defineStaticProxy(app, "/static", `${this.wwwTarget}/static`);
36+
this.defineStaticProxy(app, "/build", `${this.wwwTarget}/build`, {
37+
maxAge: "1y",
38+
immutable: true
39+
});
40+
this.defineStaticProxy(app, "/static", `${this.wwwTarget}/static`, {
41+
maxAge: "1h"
42+
});
3743
}
3844

39-
defineStaticProxy(app, proxyPath, target) {
45+
defineStaticProxy(app, proxyPath, target, serveStaticOptions = {}) {
4046
ch.background(
4147
`${this.name} server will proxy ${proxyPath} requests to ${target}.`
4248
);
43-
app.use(proxyPath, serveStatic(target));
49+
app.use(proxyPath, serveStatic(target, serveStaticOptions));
4450
}
4551

4652
defineProxy(app, proxyPath, target, logLevel = "silent") {

0 commit comments

Comments
 (0)