Assuming the server is set up correctly, modern browsers are able to automatically decompress .gzip files when they are downloaded. Is the same true for a .tar.gz file?

For example, say you have an HTML5 game with a lot of assets. It would make sense to compress the assets (game models, sound, etc.) into a single .tar file, and then (I assume) compress it again into a .gzip file. Will anything special need to be done on the client side to unpack them? Or is there a better approach to compressing assets on the server, making my question as-is sort of moot?

  • Is this programming related? Maybe stackoverflow would be better. Or if web servers then serverfault.
    – Xen2050
    Jan 31, 2019 at 11:33
  • @Xen2050 Yeah I wasn't too sure which site to ask it on. I'm not looking for a coding solution, I'm just trying to understand if I'll need to come up with a coding solution. But I first am just wondering if I can store assets on the server in a single compressed .tar.gz folder.
    – sme
    Jan 31, 2019 at 11:38
  • Did you try it? What happens?
    – Xen2050
    Jan 31, 2019 at 12:08
  • Not yet; I don't have access my server at the moment
    – sme
    Jan 31, 2019 at 12:15

1 Answer 1


The short answer is, the browser doesn't.

Most web servers can transparently gzip the data being sent to your browser to save on transmission time, but gzip is just a compression algorithm. tar, on the other hand, is a format used for batching files together into a single archive.

The longer answer is that it's the interplay between two different HTTP headers: Content-Encoding and Content-Type.

When you hit a webpage that uses gzip, you're receiving a Content-Type of text/html with a Content-Encoding of gzip. The browser knows how to handle text/html, and so it transparently uncompresses the response and renders it on your screen.

When you download a .gz or a tar file, you're receiving something with a Content-Type of application/x-gzip (or x-tar or x-tar-gz), which prompts the browser to treat the data as a file download, rather than trying to do anything with it on its own.

There's no such thing as a Content-Encoding of tar, since that header is only ever used to advertise a type of compression - so sending a .tar.gz file to a browser with gzip encoding would be pointless and wasteful. The data is already compressed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .