Skip to content

Commit

Permalink
Move cache before gzip
Browse files Browse the repository at this point in the history
  • Loading branch information
mhluska committed Aug 29, 2018
1 parent e498159 commit 304f922
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/express-http-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ class ExpressHTTPServer {

this.beforeMiddleware(app);

if (this.cache) {
app.get('/*', this.buildCacheMiddleware());
}

if (this.gzip) {
this.app.use(require('compression')());
app.use(require('compression')());
}

if (username !== undefined || password !== undefined) {
this.ui.writeLine(`adding basic auth; username=${username}; password=${password}`);
app.use(basicAuth(username, password));
}

if (this.cache) {
app.get('/*', this.buildCacheMiddleware());
}

if (this.distPath) {
app.get('/', fastbootMiddleware);
app.use(express.static(this.distPath));
Expand Down Expand Up @@ -75,12 +75,12 @@ class ExpressHTTPServer {
.then(response => {
if (response) {
this.ui.writeLine(`cache hit; path=${path}`);
res.send(response);
res.body = response;
} else {
this.ui.writeLine(`cache miss; path=${path}`);
this.interceptResponseCompletion(path, res);
next();
}
next();
})
.catch(() => next());
};
Expand Down

0 comments on commit 304f922

Please sign in to comment.