Does Windows Azure Blob Storage support serving compressed files similar to Amazon S3?

11,327

Solution 1

Azure Storage allows you to define Content-Encoding property on a blob. For compressed content, you could set this property to be GZIP and when this content is served by a browser, it automatically decompresses the content and shows the uncompressed content.

This is a bit different than Amazon S3 though where you actually have to upload 2 files. Here you will only upload one file (bundle.js in your example) which is compressed and has content-encoding set as GZIP.

Solution 2

As of 12th August 2015 Azure CDN (mounted on blob storage) now supports automatic GZip compression.

Compression method - Supported compression methods are gzip/deflate/bzip2, a supported method must be set in the Accept-Encoding Request Header.

Improve performance by compressing files

Share:
11,327
Grief Coder
Author by

Grief Coder

Web and Cloud Engineer, Architect Enjoying working with Windows Azure, ASP.NET vNext, Node.js, React...

Updated on July 18, 2022

Comments

  • Grief Coder
    Grief Coder almost 2 years

    For example, at Amazon S3, there is a convention, if you have both 'bundle.js' and 'bundle.js.gz' uploaded to the server, and a client requests for 'bundle.js' file with 'Accept-Encoding: gzip' header, Amazon S3 will serve the compressed version of this file ('bundle.js.gz' instead of 'bundle.js').

    Does Windows Azure Storage support this? If not, what are workarounds?

  • Grief Coder
    Grief Coder about 10 years
    Will it serve uncompressed content (in case browser doesn't support gzip decoding)?
  • Gaurav Mantri
    Gaurav Mantri about 10 years
    If I understand correctly, the content served will always be compressed. It is the responsibility of the consumer (browser in this case) to decompress it if it finds GZIP in content-encoding response header. So if the browser does not support GZIP decoding, it will show uncompressed content. For example, I just tried to download a compressed file via Fiddler and it showed me compressed data however if I download the same file via Firefox browser it shows me correct file data.
  • Grief Coder
    Grief Coder about 10 years
    Are you sure that if you upload both bundle.js (uncompressed) and bundle.js.gz (compressed) Azure won't serve you a compressed version if you request bundle.js with Accept-Encoding: gzip header? This seems like a standard feature. Would be sad if Azure doesn't support it yet.
  • Gaurav Mantri
    Gaurav Mantri about 10 years
    Like I said in my answer, I only uploaded bundle.js which was compressed before uploading. Let me try some more.
  • Gaurav Mantri
    Gaurav Mantri about 10 years
    So I tried the following - I uploaded bundle.js (uncompressed) and bundle.js.gz (compressed) and tried to read bundle.js through .Net code and provided Accept-Encoding: gzip request header. I got back uncompressed content. Then I tried to fetch bundle.js.gz and provided same request header. I got back compressed content. I don't think Azure supports dynamic decompression.