Compare commits
No commits in common. "917aa0fbc5078e2ed89c2114937ee5290ab184fe" and "15430a2b83d368d6eb12605d8e0dfa67295e19e3" have entirely different histories.
917aa0fbc5
...
15430a2b83
|
@ -500,8 +500,6 @@ class CacheHandler(BaseHandler):
|
||||||
self.cache[key] = pickle.dumps(data, 0)
|
self.cache[key] = pickle.dumps(data, 0)
|
||||||
|
|
||||||
def cached_response(self, req, fallback=None):
|
def cached_response(self, req, fallback=None):
|
||||||
req.from_morss_cache = True
|
|
||||||
|
|
||||||
data = self.load(req.get_full_url())
|
data = self.load(req.get_full_url())
|
||||||
|
|
||||||
if data is not None:
|
if data is not None:
|
||||||
|
@ -514,10 +512,6 @@ class CacheHandler(BaseHandler):
|
||||||
return fallback
|
return fallback
|
||||||
|
|
||||||
def save_response(self, req, resp):
|
def save_response(self, req, resp):
|
||||||
if req.from_morss_cache:
|
|
||||||
# do not re-save (would reset the timing)
|
|
||||||
return resp
|
|
||||||
|
|
||||||
data = resp.read()
|
data = resp.read()
|
||||||
|
|
||||||
self.save(req.get_full_url(), {
|
self.save(req.get_full_url(), {
|
||||||
|
@ -536,8 +530,6 @@ class CacheHandler(BaseHandler):
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
def http_request(self, req):
|
def http_request(self, req):
|
||||||
req.from_morss_cache = False # to track whether it comes from cache
|
|
||||||
|
|
||||||
data = self.load(req.get_full_url())
|
data = self.load(req.get_full_url())
|
||||||
|
|
||||||
if data is not None:
|
if data is not None:
|
||||||
|
@ -629,7 +621,8 @@ class CacheHandler(BaseHandler):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def http_response(self, req, resp):
|
def http_response(self, req, resp):
|
||||||
# code for after-fetch, to know whether to save to hard-drive (if sticking to http headers' will)
|
# code for after-fetch, to know whether to save to hard-drive (if stiking to http headers' will)
|
||||||
|
# NB. It might re-save requests pulled from cache, which will re-set the time() to the latest, i.e. lenghten its useful life
|
||||||
|
|
||||||
if resp.code == 304 and resp.url in self.cache:
|
if resp.code == 304 and resp.url in self.cache:
|
||||||
# we are hopefully the first after the HTTP handler, so no need
|
# we are hopefully the first after the HTTP handler, so no need
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
<title>RSS feed by morss</title>
|
<title>RSS feed by morss</title>
|
||||||
<meta name="viewport" content="width=device-width; initial-scale=1.0;" />
|
<meta name="viewport" content="width=device-width; initial-scale=1.0;" />
|
||||||
<meta name="robots" content="noindex" />
|
<meta name="robots" content="noindex" />
|
||||||
<link rel="shortcut icon" type="image/svg+xml" href="/logo.svg" sizes="any" />
|
|
||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
body * {
|
body * {
|
||||||
|
|
Loading…
Reference in New Issue