Browse Source

Remove ETags

pull/126/head
Lal'C Mellk Mal 3 years ago
parent
commit
08493a5007
5 changed files with 12 additions and 60 deletions
  1. +0
    -0
      client/time.js
  2. +1
    -2
      deps.js
  3. +10
    -1
      server/render.js
  4. +1
    -39
      server/server.js
  5. +0
    -18
      time/server.js

time/client.js → client/time.js View File


+ 1
- 2
deps.js View File

@@ -22,6 +22,7 @@ exports.CLIENT_DEPS = [
'client/posting.js',
'client/menu.js',
'client/conn.js',
'client/time.js',
'client/notify.js',
'client/drop.js',
'client/hide.js',
@@ -31,7 +32,6 @@ exports.CLIENT_DEPS = [
'client/gravitas.js',
'curfew/client.js',
'report/client.js',
'time/client.js',
];

exports.SERVER_DEPS = [
@@ -69,7 +69,6 @@ exports.SERVER_DEPS = [
'server/server.js',
'server/state.js',
'server/web.js',
'time/server.js',
'tripcode/tripcode.cc',
];



+ 10
- 1
server/render.js View File

@@ -19,7 +19,7 @@ function tamashii(num) {

exports.write_thread_html = function (reader, req, out, opts) {
var oneeSama = new common.OneeSama(tamashii);
oneeSama.tz_offset = req.tz_offset;
oneeSama.tz_offset = parse_timezone(req.cookies.timezone);

opts.ident = req.ident;
caps.augment_oneesama(oneeSama, opts);
@@ -212,3 +212,12 @@ exports.write_page_end = function (out, ident, returnLink) {
out.write('<script src="../mod.js"></script>\n');
}
};

function parse_timezone(tz) {
if (!tz && tz != 0)
return null;
tz = parseInt(tz, 10);
if (isNaN(tz) || tz < -24 || tz > 24)
return null;
return tz;
}

+ 1
- 39
server/server.js View File

@@ -35,7 +35,6 @@ try {
if (reportConfig.RECAPTCHA_PUBLIC_KEY)
require('../report/server');
} catch (e) {}
require('../time/server');

var RES = STATE.resources;

@@ -324,10 +323,6 @@ web.resource(/^\/(\w+)\/$/, function (req, params, cb) {
if (!caps.can_ever_access_board(req.ident, board))
return cb(404);

// we don't do board etags yet
var info = {etag: 'dummy', req: req};
hooks.trigger_sync('buildETag', info);

cb(null, 'ok', {board: board});
},
function (req, resp) {
@@ -387,10 +382,6 @@ web.resource(/^\/(\w+)\/page(\d+)$/, function (req, params, cb) {
yaku.disconnect();
});
yaku.once('begin', function (threadCount) {
// we don't do board etags yet
var info = {etag: 'dummy', req: req};
hooks.trigger_sync('buildETag', info);

cb(null, 'ok', {
board: board, page: page, yaku: yaku,
threadCount: threadCount,
@@ -500,36 +491,7 @@ web.resource(/^\/(\w+)\/(\d+)$/, function (req, params, cb) {
yaku.disconnect();
});
reader.once('begin', function (preThread) {
var headers;
if (!config.DEBUG && preThread.hctr) {
var etag = 'W/' + preThread.hctr + '-' + RES.indexHash;

var thumb = req.cookies.thumb;
if (thumb && common.thumbStyles.indexOf(thumb) >= 0)
etag += '-' + thumb;
if (lastN)
etag += '-last' + lastN;
if (preThread.locked)
etag += '-locked';
if (req.ident.auth)
etag += '-auth';

var info = {etag: etag, req: req};
hooks.trigger_sync('buildETag', info);
etag = info.etag;

if (req.headers['if-none-match'] === etag) {
yaku.disconnect();
return cb(null, 304);
}
headers = _.clone(web.vanillaHeaders);
headers.ETag = etag;
headers['Cache-Control'] = (
'private, max-age=0, must-revalidate');
}
else
headers = web.noCacheHeaders;

var headers = web.noCacheHeaders;
cb(null, 'ok', {
headers: headers,
board: board, op: op,


+ 0
- 18
time/server.js View File

@@ -1,18 +0,0 @@
var hooks = require('../hooks');

function parse_timezone(tz) {
if (!tz && tz != 0)
return null;
tz = parseInt(tz, 10);
if (isNaN(tz) || tz < -24 || tz > 24)
return null;
return tz;
}

hooks.hook_sync('buildETag', function (info) {
var tz = parse_timezone(info.req.cookies.timezone);
if (tz) {
info.req.tz_offset = tz;
info.etag += '-tz' + tz;
}
});

Loading…
Cancel
Save