From d3c163fb74d2dced697cfaea4cb7a4a2b2990bb1 Mon Sep 17 00:00:00 2001 From: pictuga Date: Sat, 24 Aug 2013 23:43:32 +0200 Subject: [PATCH] Use ETag for user-side caching Pretty hard-code ETag use. ETag is just a timestamp, and the server checks whether it's recent enough. --- morss.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/morss.py b/morss.py index 1795860..0d6eb81 100644 --- a/morss.py +++ b/morss.py @@ -412,7 +412,16 @@ if __name__ == '__main__': log(url) if 'REQUEST_URI' in os.environ: + if 'HTTP_IF_NONE_MATCH' in os.environ: + log('etag sent') + if time.time() - int(os.environ['HTTP_IF_NONE_MATCH'][1:-1]) < DELAY: + log('etag good') + print 'Status: 304' + print + sys.exit(0) + print 'Status: 200' + print 'ETag: "%s"' % int(time.time()) if options == 'progress': print 'Content-Type: application/octet-stream'