Support If-Modified-Since in cross-site thread watcher requests.
This commit is contained in:
parent
7b2dee7279
commit
4b7b139311
@ -183,19 +183,15 @@ ThreadWatcher =
|
|||||||
else
|
else
|
||||||
ThreadWatcher.status.textContent = "#{Math.round(ThreadWatcher.fetched / ThreadWatcher.requests.length * 100)}%"
|
ThreadWatcher.status.textContent = "#{Math.round(ThreadWatcher.fetched / ThreadWatcher.requests.length * 100)}%"
|
||||||
cb.apply @, args
|
cb.apply @, args
|
||||||
if siteID is Site.hostname
|
ajax = if siteID is Site.hostname then $.ajax else CrossOrigin.ajax
|
||||||
if force
|
if force
|
||||||
delete $.lastModified.ThreadWatcher?[url]
|
delete $.lastModified.ThreadWatcher?[url]
|
||||||
req = $.whenModified(
|
req = $.whenModified(
|
||||||
url,
|
url,
|
||||||
'ThreadWatcher',
|
'ThreadWatcher',
|
||||||
onloadend,
|
onloadend,
|
||||||
{timeout: $.MINUTE}
|
{timeout: $.MINUTE, ajax}
|
||||||
)
|
)
|
||||||
else
|
|
||||||
req = CrossOrigin.ajax url,
|
|
||||||
onloadend: onloadend
|
|
||||||
timeout: $.MINUTE
|
|
||||||
ThreadWatcher.requests.push req
|
ThreadWatcher.requests.push req
|
||||||
|
|
||||||
clearRequests: ->
|
clearRequests: ->
|
||||||
|
|||||||
@ -82,7 +82,7 @@ $.ajax = do ->
|
|||||||
# This saves a lot of bandwidth and CPU time for both the users and the servers.
|
# This saves a lot of bandwidth and CPU time for both the users and the servers.
|
||||||
$.lastModified = {}
|
$.lastModified = {}
|
||||||
$.whenModified = (url, bucket, cb, options={}) ->
|
$.whenModified = (url, bucket, cb, options={}) ->
|
||||||
{timeout} = options
|
{timeout, ajax} = options
|
||||||
params = []
|
params = []
|
||||||
# XXX https://bugs.chromium.org/p/chromium/issues/detail?id=643659
|
# XXX https://bugs.chromium.org/p/chromium/issues/detail?id=643659
|
||||||
params.push "s=#{bucket}" if $.engine is 'blink'
|
params.push "s=#{bucket}" if $.engine is 'blink'
|
||||||
@ -92,7 +92,7 @@ $.whenModified = (url, bucket, cb, options={}) ->
|
|||||||
headers = {}
|
headers = {}
|
||||||
if (t = $.lastModified[bucket]?[url0])?
|
if (t = $.lastModified[bucket]?[url0])?
|
||||||
headers['If-Modified-Since'] = t
|
headers['If-Modified-Since'] = t
|
||||||
r = $.ajax url, {
|
r = (ajax or $.ajax) url, {
|
||||||
onloadend: ->
|
onloadend: ->
|
||||||
($.lastModified[bucket] or= {})[url0] = @getResponseHeader('Last-Modified')
|
($.lastModified[bucket] or= {})[url0] = @getResponseHeader('Last-Modified')
|
||||||
cb.call @
|
cb.call @
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user