From 52128775e1edb69f83c93526516e6531511725fd Mon Sep 17 00:00:00 2001 From: ccd0 Date: Fri, 8 Mar 2019 03:30:01 -0800 Subject: [PATCH] Restore forced If-Modified-Since for intra-site thread watcher requests. --- src/Monitoring/ThreadStats.coffee | 1 + src/Monitoring/ThreadUpdater.coffee | 1 + src/Monitoring/ThreadWatcher.coffee | 2 ++ src/platform/$.coffee | 4 ++-- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Monitoring/ThreadStats.coffee b/src/Monitoring/ThreadStats.coffee index a274ac80a..ca210334d 100644 --- a/src/Monitoring/ThreadStats.coffee +++ b/src/Monitoring/ThreadStats.coffee @@ -77,6 +77,7 @@ ThreadStats = ThreadStats.timeout = setTimeout ThreadStats.fetchPage, 2 * $.MINUTE $.ajax "#{location.protocol}//a.4cdn.org/#{ThreadStats.thread.board}/threads.json", onload: ThreadStats.onThreadsLoad, whenModified: 'ThreadStats' + bypassCache: true onThreadsLoad: -> if @status is 200 diff --git a/src/Monitoring/ThreadUpdater.coffee b/src/Monitoring/ThreadUpdater.coffee index 2e940d838..c44851170 100644 --- a/src/Monitoring/ThreadUpdater.coffee +++ b/src/Monitoring/ThreadUpdater.coffee @@ -236,6 +236,7 @@ ThreadUpdater = timeout: $.MINUTE , whenModified: 'ThreadUpdater' + bypassCache: true updateThreadStatus: (type, status) -> return if not (hasChanged = ThreadUpdater.thread["is#{type}"] isnt status) diff --git a/src/Monitoring/ThreadWatcher.coffee b/src/Monitoring/ThreadWatcher.coffee index f4f95cd7d..d63002850 100644 --- a/src/Monitoring/ThreadWatcher.coffee +++ b/src/Monitoring/ThreadWatcher.coffee @@ -224,6 +224,8 @@ ThreadWatcher = onloadend: -> ThreadWatcher.parseStatus.call @, thread timeout: $.MINUTE + , + whenModified: if force then false else 'ThreadWatcher' else req = {abort: () -> req.aborted = true} CrossOrigin.json url, -> diff --git a/src/platform/$.coffee b/src/platform/$.coffee index 241c5fbb4..78697a9db 100644 --- a/src/platform/$.coffee +++ b/src/platform/$.coffee @@ -51,7 +51,7 @@ $.ajax = do -> pageXHR = XMLHttpRequest (url, options={}, extra={}) -> - {type, whenModified, upCallbacks, form} = extra + {type, whenModified, bypassCache, upCallbacks, form} = extra options.responseType ?= 'json' if /\.json$/.test url # XXX https://forums.lanik.us/viewtopic.php?f=64&t=24173&p=78310 url = url.replace /^((?:https?:)?\/\/(?:\w+\.)?4c(?:ha|d)n\.org)\/adv\//, '$1//adv/' @@ -59,7 +59,7 @@ $.ajax = do -> params = [] # XXX https://bugs.chromium.org/p/chromium/issues/detail?id=643659 params.push "s=#{whenModified}" if $.engine is 'blink' - params.push "t=#{Date.now()}" if Site.software is 'yotsuba' + params.push "t=#{Date.now()}" if Site.software is 'yotsuba' and bypassCache url0 = url url += '?' + params.join('&') if params.length r = new pageXHR()