From 073444c55a95ba742fa71b0f2ca0a51fc8318ae9 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 13 Apr 2020 21:59:56 +0100 Subject: [PATCH] Etags on background images --- daemon.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/daemon.py b/daemon.py index 4dd2e1843..3c0f47ae7 100644 --- a/daemon.py +++ b/daemon.py @@ -1772,6 +1772,10 @@ class PubServer(BaseHTTPRequestHandler): avatarNickname + '@' + \ self.server.domain + '/' + avatarFile if os.path.isfile(avatarFilename): + if self._etag_exists(avatarFilename): + # The file has not changed + self._304() + return mediaImageType = 'png' if avatarFile.endswith('.png'): mediaImageType = 'png' @@ -1783,9 +1787,10 @@ class PubServer(BaseHTTPRequestHandler): mediaImageType = 'webp' with open(avatarFilename, 'rb') as avFile: mediaBinary = avFile.read() - self._set_headers('image/' + mediaImageType, - len(mediaBinary), cookie, - callingDomain) + self._set_headers_etag(avatarFilename, + 'image/' + mediaImageType, + mediaBinary, cookie, + callingDomain) self._write(mediaBinary) return