diff options
-rw-r--r-- | fietsboek/views/detail.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/fietsboek/views/detail.py b/fietsboek/views/detail.py index 38dc31f..a135916 100644 --- a/fietsboek/views/detail.py +++ b/fietsboek/views/detail.py @@ -59,7 +59,13 @@ def gpx(request): :rtype: pyramid.response.Response """ track = request.context - response = Response(track.gpx_data, content_type="application/gpx+xml") + # We can be nice to the client if they support it, and deliver the gzipped + # data straight. This saves decompression time on the server and saves a + # lot of bandwidth. + if 'gzip' in request.accept_encoding: + response = Response(track.gpx, content_type="application/gpx+xml", content_encoding="gzip") + else: + response = Response(track.gpx_data, content_type="application/gpx+xml") response.md5_etag() return response |