Skip to content

Commit cc9bb10

Browse files
committed
2 parents 8ab8df5 + bab3c95 commit cc9bb10

File tree

1 file changed

+61
-2
lines changed

1 file changed

+61
-2
lines changed

README.md

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,61 @@
1-
# azure-storage-gzip-encoding
2-
A utility to facilitate configuring Azure Blob storage to return gzip compressed HTTP responses directly, or through Azure CDN.
1+
[![Build status](https://ci.appveyor.com/api/projects/status/5b7d5wk4pwv21htt?svg=true)](https://ci.appveyor.com/project/stefangordon/azure-storage-gzip-encoding)
2+
3+
# Azure Storage GZip Encoding
4+
A utility to automatically configure [HTTP Compression](https://en.wikipedia.org/wiki/HTTP_compression) for blobs in Azure Blob storage. Blobs can be consumed directly from a client browser or via Azure CDN.
5+
6+
This tool is inspired by a code sample from David Rousset for optimizing BablyonJS Assets.
7+
8+
## Why
9+
Azure storage is an excellent option for storing assets and data consumed by web applications, but it is often preferable to have this data delivered to the browser compressed. Azure CDN can be used to provide compression and performance improvements on top of blob storage but has an upper limit of 1MB for HTTP compression.
10+
11+
Azure Blob Storage is capable of delivering the correct `content-encoding: gzip` headers directly, but data must be compressed in storage, and the headers must be configured correctly. Then this content is delivered compressed either directly or through CDN.
12+
13+
Managing this manual compression and configuration of headers yourself would be tedious, but this tool can be run to do it for you, and happily ignores files that are already compressed. You can run it automatically as part of a build process, or manually on an as-needed basis.
14+
15+
## What it does
16+
The utility can enumerate all of the files in a container. It then filters to files matching your provided extensions. These files are compressed using GZip and the content-encoding and cache headers are configured on them so they are compatible with all browsers HTTP compression features. The tool will not alter a file which is already compressed (based on inspecting the headers), so it is safe to run multiple times to catch new files.
17+
18+
## Getting Started
19+
You must provide
20+
- Either an account name and key, or connection string
21+
- Container to enumerate (recursively)
22+
- List of file extensions to operate on
23+
- Whether to replace existing files with compressed version, or copy with a new extension
24+
25+
## Examples
26+
27+
Replacing .css files in-place. Blobs will be replaced with compressed version and headers updated:
28+
`asge.exe -e .css -f myContainer -r -a myStorageAccount -k <key>`
29+
30+
Copy .css and .js to a compressed version and append a .gz extension:
31+
`asge.exe -e .css .js -f myContainer -n .gz -a myStorageAccount -k <key>`
32+
33+
```
34+
-a, --account Storage account host. [mystorage]
35+
36+
-k, --key Storage account key.
37+
38+
-c, --connectionstring Storage account key.
39+
40+
-e, --extensions Required. Extensions to operate on. [.js, .css,
41+
.dat]
42+
43+
-r, --replace (Default: False) Replace existing files in-place.
44+
45+
-s, --simulate (Default: False) Do everything except write to blob
46+
store.
47+
48+
-n, --newextension Copy file with a new postfix. [.gz]
49+
50+
-f, --container Required. Container to search in.
51+
52+
-x, --cacheage (Default: 2592000) Duration for cache control max
53+
age header, in seconds. Default 2592000 (30 days).
54+
55+
--help Display this help screen.
56+
```
57+
58+
## Current State
59+
Only block blobs are supported.
60+
61+
The tool has had only light testing at this point. Ensure that you have backups of all your binary data before running the tool so that you can recover in the event a blob is corrupted.

0 commit comments

Comments
 (0)