From d8ce9e645365f5988b5ee271b5a28dceb1f2dc80 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 23 Jul 2022 20:38:31 +0200 Subject: add ETags to gpx and badge files We cannot add them to image files, because FileResponse may use the wsgi provided file sending mechanism right when the object is created. FileResponse does however use the Last-Modified header, which is also okay. --- fietsboek/views/detail.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fietsboek/views/detail.py b/fietsboek/views/detail.py index 80d112b..1808bda 100644 --- a/fietsboek/views/detail.py +++ b/fietsboek/views/detail.py @@ -55,7 +55,9 @@ def gpx(request): :rtype: pyramid.response.Response """ track = request.context - return Response(track.gpx_data, content_type="application/gpx+xml") + response = Response(track.gpx_data, content_type="application/gpx+xml") + response.md5_etag() + return response @view_config(route_name='invalidate-share', request_method='POST', permission='track.unshare') @@ -98,7 +100,9 @@ def badge(request): :return: The HTTP response. :rtype: pyramid.response.Response """ - return Response(request.context.image) + response = Response(request.context.image) + response.md5_etag() + return response @view_config(route_name='image', http_cache=3600, permission='track.view') -- cgit v1.2.3