From 12ad6b02fe8f283865b01fd262ecbb3fb0fc1251 Mon Sep 17 00:00:00 2001 From: j Date: Sun, 14 Jan 2018 20:42:23 +0100 Subject: [PATCH] send redirect, otherwise nginx takes expiry for static url --- pandora/item/views.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/pandora/item/views.py b/pandora/item/views.py index e8a4e019..7fe2dd35 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -878,11 +878,8 @@ def poster(request, id, size=None): if item.poster and os.path.exists(item.poster.path): return image_to_response(item.poster, size) else: - poster_path = os.path.join(settings.STATIC_ROOT, 'jpg/poster.jpg') - response = HttpFileResponse(poster_path, content_type='image/jpeg') - response['Cache-Control'] = 'no-cache' - response['Expires'] = datetime.strftime(datetime.utcnow() - timedelta(days=1), "%a, %d-%b-%Y %H:%M:%S GMT") - return response + poster_url = os.path.join(settings.STATIC_URL, 'jpg/poster.jpg') + return redirect(stream.media.url) def icon(request, id, size=None): item = get_object_or_404(models.Item, public_id=id) @@ -891,11 +888,8 @@ def icon(request, id, size=None): if item.icon and os.path.exists(item.icon.path): return image_to_response(item.icon, size) else: - poster_path = os.path.join(settings.STATIC_ROOT, 'jpg/poster.jpg') - response = HttpFileResponse(poster_path, content_type='image/jpeg') - response['Cache-Control'] = 'no-cache' - response['Expires'] = datetime.strftime(datetime.utcnow() - timedelta(days=1), "%a, %d-%b-%Y %H:%M:%S GMT") - return response + poster_url = os.path.join(settings.STATIC_URL, 'jpg/poster.jpg') + return redirect(stream.media.url) def timeline(request, id, size, position=-1, format='jpg', mode=None): item = get_object_or_404(models.Item, public_id=id)