Headers should only be set after file is written.

pull/521/head
Chad Weider 2012-02-28 18:08:03 -08:00
parent 24a26953a7
commit 118e7928b9
1 changed files with 4 additions and 2 deletions

View File

@ -91,7 +91,6 @@ CachingMiddleware.prototype = new function () {
res.setHeader(key, headers[key]); res.setHeader(key, headers[key]);
}); });
headers = _headers; headers = _headers;
responseCache[cacheKey] = {statusCode: status, headers: headers};
old_res.write = res.write; old_res.write = res.write;
old_res.end = res.end; 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) { } else if (status == 304) {
// Nothing new changed from the cached version. // Nothing new changed from the cached version.