Merge pull request #1001 from tcely/patch-2

Do not cache the blank thumbnail for so long
This commit is contained in:
meeb authored and GitHub committed 2025-05-01 13:25:33 +10:00
commit de765d41dc
1 file changed
+6 -3
+6 -3
View File
@@ -523,6 +523,9 @@ class MediaThumbView(DetailView):
def get(self, request, *args, **kwargs):
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:
thumb_path = pathlib.Path(media.thumb.path)
thumb = thumb_path.read_bytes()
@@ -532,10 +535,10 @@ class MediaThumbView(DetailView):
thumb = b64decode('R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAA'
'AAAABAAEAAAICTAEAOw==')
content_type = 'image/gif'
max_age = 600
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'] = 'public, max-age=604800'
response['Cache-Control'] = f'public, max-age={max_age}'
return response