diff options
author | François Schmidts <francois.schmidts@gmail.com> | 2015-07-06 14:20:21 +0200 |
---|---|---|
committer | François Schmidts <francois.schmidts@gmail.com> | 2015-07-06 14:36:47 +0200 |
commit | da4a415176c5d91a2310666ab597224591d3957c (patch) | |
tree | 2e1054449ec4707c3d6fec80f19be739b59b8daf /pyaggr3g470r | |
parent | the icon isn't a url but a b64 dump (diff) | |
download | newspipe-da4a415176c5d91a2310666ab597224591d3957c.tar.gz newspipe-da4a415176c5d91a2310666ab597224591d3957c.tar.bz2 newspipe-da4a415176c5d91a2310666ab597224591d3957c.zip |
adding cache control on icons
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r-- | pyaggr3g470r/views/feed.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/pyaggr3g470r/views/feed.py b/pyaggr3g470r/views/feed.py index d84a68bc..3556d7c7 100644 --- a/pyaggr3g470r/views/feed.py +++ b/pyaggr3g470r/views/feed.py @@ -1,6 +1,7 @@ #! /usr/bin/env python # -*- coding: utf-8 - import base64 +from hashlib import md5 from datetime import datetime from sqlalchemy import desc from werkzeug.exceptions import BadRequest @@ -186,6 +187,11 @@ def process_form(feed_id=None): @feed_bp.route('/icon/<int:feed_id>', methods=['GET']) +@login_required def icon(feed_id): - return Response(base64.b64decode(FeedController().get(id=feed_id).icon), - mimetype='image') + icon = FeedController(g.user.id).get(id=feed_id).icon + etag = md5(icon.encode('utf8')).hexdigest() + headers = {'Cache-Control': 'max-age=86400', 'ETag': etag} + if request.headers.get('if-none-match') == etag: + return Response(status=304, headers=headers) + return Response(base64.b64decode(icon), mimetype='image', headers=headers) |