mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
Catch 304's early.
This commit is contained in:
parent
d6d4178dbc
commit
c2669360d1
1 changed files with 19 additions and 12 deletions
|
@ -69,21 +69,28 @@ exports.minifyJS = function(req, res, next)
|
||||||
|
|
||||||
function _handle(req, res, jsFilename, jsFiles) {
|
function _handle(req, res, jsFilename, jsFiles) {
|
||||||
res.header("Content-Type","text/javascript");
|
res.header("Content-Type","text/javascript");
|
||||||
|
|
||||||
//minifying is enabled
|
lastModifiedDate(function (date) {
|
||||||
if(settings.minify)
|
date = new Date(date);
|
||||||
|
res.setHeader('last-modified', date.toUTCString());
|
||||||
|
res.setHeader('date', (new Date()).toUTCString());
|
||||||
|
|
||||||
|
if (new Date(req.headers['if-modified-since']) >= date) {
|
||||||
|
res.writeHead(304, {});
|
||||||
|
res.end();
|
||||||
|
} else if (settings.minify) {
|
||||||
|
respondMinified();
|
||||||
|
} else {
|
||||||
|
respondRaw();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function respondMinified()
|
||||||
{
|
{
|
||||||
var result = undefined;
|
var result = undefined;
|
||||||
var latestModification = 0;
|
var latestModification = new Date(res.getHeader('last-modified'));
|
||||||
|
|
||||||
async.series([
|
async.series([
|
||||||
//find out the highest modification date
|
|
||||||
function (callback) {
|
|
||||||
lastModifiedDate(function (date) {
|
|
||||||
latestModification = date;
|
|
||||||
callback()
|
|
||||||
});
|
|
||||||
},
|
|
||||||
function(callback)
|
function(callback)
|
||||||
{
|
{
|
||||||
//check the modification time of the minified js
|
//check the modification time of the minified js
|
||||||
|
@ -169,7 +176,7 @@ function _handle(req, res, jsFilename, jsFiles) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
//minifying is disabled, so put the files together in one file
|
//minifying is disabled, so put the files together in one file
|
||||||
else
|
function respondRaw()
|
||||||
{
|
{
|
||||||
tarCode(
|
tarCode(
|
||||||
jsFiles
|
jsFiles
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue