From d4656563325c0a4a285ba37762f9b3f6e9c56fed Mon Sep 17 00:00:00 2001 From: AirBorne04 Date: Wed, 17 Aug 2016 16:12:31 +0200 Subject: [PATCH 1/2] slow "time to first byte" on logged in state When the user is logged in the browser measure for time to first byte is very slow (1.5s). I am testing with a remote mongodb which might contribute to the issue. In that situation also responses for js-files, assets and css all suffer the same initial delay. My debugging brought me to the conclusion that the handleOnAllRoutes has some side effect that is causing this. I do not see a reason why handleOnAllRoutes would need to run on every request and especially for static files / assets? Therefore i wrapped the call to handleOnAllRoutes into the picker route when we are anticipating an html rendering to occur. --- server/route.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server/route.js b/server/route.js index 28d68a5..6ed8750 100644 --- a/server/route.js +++ b/server/route.js @@ -12,11 +12,16 @@ Route = class extends SharedRoute { _init() { const cookieParser = require('cookie-parser'); Picker.middleware(cookieParser()); - // process null subscriptions with FR support - Picker.middleware(FastRender.handleOnAllRoutes); const route = FlowRouter.basePath + this.pathDef; - Picker.route(route, this._handleRoute.bind(this)); + + // only run fast render for defined routes + Picker.route(route, (params, req, res, next) => { + // process null subscriptions with FR support + FastRender.handleOnAllRoutes(req, res, () => { + this._handleRoute.bind(this)(params, req, res, next); + }); + }); } _handleRoute(params, req, res, next) { From 910842f6414619d78c12283ec1994eb93bff2c2a Mon Sep 17 00:00:00 2001 From: AirBorne04 Date: Mon, 22 Aug 2016 13:06:07 +0200 Subject: [PATCH 2/2] trailing whitespace removed travis build failed due to trailing whitespace --- server/route.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/route.js b/server/route.js index 6ed8750..01c366a 100644 --- a/server/route.js +++ b/server/route.js @@ -14,7 +14,7 @@ Route = class extends SharedRoute { Picker.middleware(cookieParser()); const route = FlowRouter.basePath + this.pathDef; - + // only run fast render for defined routes Picker.route(route, (params, req, res, next) => { // process null subscriptions with FR support