Rub21 left a comment (openstreetmap/openstreetmap-website#7124)
@pablobm you're right that this could add real bandwidth and CPU cost. I looked
into it a bit more.
I think we can avoid it without hiding the link, using the `Content-Encoding:
gzip` header. The file is already stored gzipped on S3, so we send it as-is and
the browser unzips it by itself. The server does nothing and sends the small
file.
Browsers always send Accept-Encoding: gzip, so this happens on its own and the
user still gets a normal .gpx
I tested it with curl --compressed, which behaves like a browser:
```
$ curl -s --compressed -D - http://localhost:3000/traces/1/data.gpx -o out.gpx
content-encoding: gzip
content-length: 2025 # 2 KB over the network
$ file out.gpx
out.gpx: XML document text # plain GPX on disk
$ wc -c out.gpx
15796 # 15.8 KB unzipped by the client
```
If a client doesn't support gzip, the server unzips the file and sends it
plain, same as today, so nothing breaks. Other formats work the same way too:
we still serve whatever the user uploaded. And since the backend decides this
from the request header, one download link is enough now, so I kept just one.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/7124#issuecomment-4616958090
You are receiving this because you are subscribed to this thread.
Message ID:
<openstreetmap/openstreetmap-website/pull/7124/[email protected]>
_______________________________________________
rails-dev mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/rails-dev