mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-24 05:56:37 +00:00
Do not cache the blank thumbnail for so long
This commit is contained in:
parent
f03db23298
commit
f724c5765f
@ -523,6 +523,9 @@ class MediaThumbView(DetailView):
|
|||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
media = self.get_object()
|
media = self.get_object()
|
||||||
|
# Thumbnail media is never updated so we can ask the browser to cache it
|
||||||
|
# for ages, 604800 = 7 days
|
||||||
|
max_age = 604800
|
||||||
if media.thumb_file_exists:
|
if media.thumb_file_exists:
|
||||||
thumb_path = pathlib.Path(media.thumb.path)
|
thumb_path = pathlib.Path(media.thumb.path)
|
||||||
thumb = thumb_path.read_bytes()
|
thumb = thumb_path.read_bytes()
|
||||||
@ -532,10 +535,10 @@ class MediaThumbView(DetailView):
|
|||||||
thumb = b64decode('R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAA'
|
thumb = b64decode('R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAA'
|
||||||
'AAAABAAEAAAICTAEAOw==')
|
'AAAABAAEAAAICTAEAOw==')
|
||||||
content_type = 'image/gif'
|
content_type = 'image/gif'
|
||||||
|
max_age = 600
|
||||||
response = HttpResponse(thumb, content_type=content_type)
|
response = HttpResponse(thumb, content_type=content_type)
|
||||||
# Thumbnail media is never updated so we can ask the browser to cache it
|
|
||||||
# for ages, 604800 = 7 days
|
response['Cache-Control'] = f'public, max-age={max_age}'
|
||||||
response['Cache-Control'] = 'public, max-age=604800'
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user