From 118e7928b96f771127775486b2a84f3cd8cba824 Mon Sep 17 00:00:00 2001 From: Chad Weider Date: Tue, 28 Feb 2012 18:08:03 -0800 Subject: [PATCH] Headers should only be set after file is written. --- node/utils/caching_middleware.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/node/utils/caching_middleware.js b/node/utils/caching_middleware.js index 8c51f662..b0da22dc 100644 --- a/node/utils/caching_middleware.js +++ b/node/utils/caching_middleware.js @@ -91,7 +91,6 @@ CachingMiddleware.prototype = new function () { res.setHeader(key, headers[key]); }); headers = _headers; - responseCache[cacheKey] = {statusCode: status, headers: headers}; old_res.write = res.write; old_res.end = res.end; @@ -118,7 +117,10 @@ CachingMiddleware.prototype = new function () { } }); } - ], respond); + ], function () { + responseCache[cacheKey] = {statusCode: status, headers: headers}; + respond(); + }); }; } else if (status == 304) { // Nothing new changed from the cached version.