From 5c4606430681f82aa3df2d0d9d6302d77984c1e0 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Fri, 29 Aug 2014 22:22:37 -0700 Subject: [PATCH] remove stale requests from cache on index refresh --- src/General/Index.coffee | 1 + src/General/lib/$.coffee | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 1ad465b22..9717041f1 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -289,6 +289,7 @@ Index = Index.scrollToIndex() parse: (pages, pageNum) -> + $.cleanCache (url) -> /^\/\/a\.4cdn\.org\//.test url Index.parseThreadList pages Index.buildThreads() Index.sort() diff --git a/src/General/lib/$.coffee b/src/General/lib/$.coffee index f0c485117..2a0309032 100755 --- a/src/General/lib/$.coffee +++ b/src/General/lib/$.coffee @@ -72,9 +72,9 @@ $.ajax = do -> r.send form r -$.cache = do -> +do -> reqs = {} - (url, cb, options) -> + $.cache = (url, cb, options) -> if req = reqs[url] if req.readyState is 4 cb.call req, req.evt @@ -93,6 +93,10 @@ $.cache = do -> $.on req, 'abort error', rm req.callbacks = [cb] reqs[url] = req + $.cleanCache = (testf) -> + for url of reqs when testf url + delete reqs[url] + return $.cb = checked: ->