send redirect, otherwise nginx takes expiry for static url

This commit is contained in:
j 2018-01-14 20:42:23 +01:00
parent 341e1bd892
commit 12ad6b02fe

View file

@ -878,11 +878,8 @@ def poster(request, id, size=None):
if item.poster and os.path.exists(item.poster.path): if item.poster and os.path.exists(item.poster.path):
return image_to_response(item.poster, size) return image_to_response(item.poster, size)
else: else:
poster_path = os.path.join(settings.STATIC_ROOT, 'jpg/poster.jpg') poster_url = os.path.join(settings.STATIC_URL, 'jpg/poster.jpg')
response = HttpFileResponse(poster_path, content_type='image/jpeg') return redirect(stream.media.url)
response['Cache-Control'] = 'no-cache'
response['Expires'] = datetime.strftime(datetime.utcnow() - timedelta(days=1), "%a, %d-%b-%Y %H:%M:%S GMT")
return response
def icon(request, id, size=None): def icon(request, id, size=None):
item = get_object_or_404(models.Item, public_id=id) 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): if item.icon and os.path.exists(item.icon.path):
return image_to_response(item.icon, size) return image_to_response(item.icon, size)
else: else:
poster_path = os.path.join(settings.STATIC_ROOT, 'jpg/poster.jpg') poster_url = os.path.join(settings.STATIC_URL, 'jpg/poster.jpg')
response = HttpFileResponse(poster_path, content_type='image/jpeg') return redirect(stream.media.url)
response['Cache-Control'] = 'no-cache'
response['Expires'] = datetime.strftime(datetime.utcnow() - timedelta(days=1), "%a, %d-%b-%Y %H:%M:%S GMT")
return response
def timeline(request, id, size, position=-1, format='jpg', mode=None): def timeline(request, id, size, position=-1, format='jpg', mode=None):
item = get_object_or_404(models.Item, public_id=id) item = get_object_or_404(models.Item, public_id=id)