Restore forced If-Modified-Since for intra-site thread watcher requests.

This commit is contained in:
ccd0 2019-03-08 03:30:01 -08:00
parent 4ca1b1450c
commit 52128775e1
4 changed files with 6 additions and 2 deletions

View File

@ -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

View File

@ -236,6 +236,7 @@ ThreadUpdater =
timeout: $.MINUTE
,
whenModified: 'ThreadUpdater'
bypassCache: true
updateThreadStatus: (type, status) ->
return if not (hasChanged = ThreadUpdater.thread["is#{type}"] isnt status)

View File

@ -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, ->

View File

@ -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()