Skip to content

Commit 88a72ed

Browse files
Set cache control headers for static assets
1 parent 7943dba commit 88a72ed

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

bin/ember-fastboot

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
const FastBootAppServer = require('fastboot-app-server');
66
const ExpressHTTPServer = require('fastboot-app-server/src/express-http-server');
77
const parseArgs = require('minimist');
8+
const express = require('express');
89
const { URL } = require('url');
910

1011
// Provide a title to the process in `ps`
@@ -26,7 +27,6 @@ if (!distPath) {
2627
}
2728

2829
const serverOptions = {
29-
// assetsCacheControl: 'max-age=365000000, immutable',
3030
distPath,
3131
gzip: false, // Let Fastly take care of compression, reducing load on the fastboot
3232
};
@@ -35,6 +35,12 @@ const httpServer = new ExpressHTTPServer(serverOptions);
3535

3636
const app = httpServer.app;
3737

38+
app.use(express.static(distPath, {
39+
setHeaders(res, path, stat) {
40+
res.setHeader('Cache-Control', 'public, max-age=365000000, immutable');
41+
}
42+
}));
43+
3844
/** We rewrite the 307 location header into a relativeURL so that our special setup is handled */
3945
app.use(function(req, res, next) {
4046
const originalSendFn = res.send;

0 commit comments

Comments
 (0)