How to enable gzip compression for Edge Application

Gzip is the standard method for lossless file compression for web applications. By using the Deflate algorithm to reduce the size of files before they are sent to browsers, gzip compression ensures faster page rendering and downloads for your users.

See the official gzip website for useful links and information.

When you enable gzip compression for Azion Edge Application, the following events take place during a request for content from your application:

  1. At the edge node, Azion verifies the cache for a compressed version of the file.
  2. If the file’s already compressed, it’s delivered to the browser. If it isn’t, Azion compresses the file, returns it to the browser, and adds it to the cache.
  3. The browser interprets and decompresses the file.

Enabling gzip compression through Rules Engine

Section titled Enabling gzip compression through Rules Engine

You can enable gzip compression for any edge application using the Rules Engine for Edge Application.

To enable gzip compression for your application, follow these steps:

  1. Access Azion Console.

  2. Select Products menu > Edge Application.

  3. Click on the application you want to configure or build a new one.

  4. In the Rules Engine tab, click the Add Rule button and select either Response Phase or Request Phase.

  5. In the Criteria section, define the desired criteria for activation of the behavior.

    To apply gzip compression for your entire application, you can set a default criteria as follows:

    If ${uri} starts with /

  6. In the Behavior section, select the Enable gzip behavior.

  7. Click the Save button.

To verify whether gzip compression has been applied, access your application and inspect the page. The Content-Encoding request header should contain the value gzip.

Azion servers support gzip compression for some file extensions, which are identified via their MIME (Multipurpose Internet Mail Extensions) type.

Whenever a page loads within a web browser, a web server sends information regarding the contents and data of the page to the browser. Such details are stored in request headers and they are passed to the browser so that it can load and interpret the page.

The Content-Type header is responsible for processing page contents through the MIME type. MIME types inform the types of documents, files, or byte arrays within the web application, as well as how they should be processed.

MIME types consist of a type and subtype combined by a / symbol in between each other. The type represents the category of that data file; for instance, text or image. The subtype stands for the exact data type represented by the MIME type. For instance, the MIME type image could carry a subtype jpeg or png.

Therefore, when your browser runs into an <img> HTML tag, it sends out a request to the server. If this image is a .png, the server will return the header and MIME type: Content-Type: image/png.

The entity responsible for all official MIME types is the Internet Assigned Numbers Authority (IANA).

Files that have undergone gzip compression should retain their original MIME type on the request header, since the browser is responsible for decompressing the file upon the end of the request.

List of supported MIME types for gzip compression

Section titled List of supported MIME types for gzip compression
MIME TypeExtensionDocument type
application/eot.eotMS Embedded OpenType fonts
application/fontOpenType font
SFNT format
application/font-woff.woffWeb Open Font Format (WOFF)
application/font-woff2.woff2Web Open Font Format 2 (WOFF2)
application/json.jsonJSON format
application/ld+json.jsonldJSON-LD format
application/ Embedded OpenType fonts
CGI scripts/programs
application/x-mpegurl.M3U8iPhone Index
application/x-opentype.ttcOpenType font
application/x-otf.otfOpenType font
Perl script
RSS, Atom and XML
font/eot.eotEmbedded Open Type
OpenType font
font/otf.otfOpenType font
font/ttf.ttfTrueType font
image/svg+xml.svgScalable Vector Graphics (SVG)
text/css.cssCascading Style Sheets (CSS)
text/csv.csvComma-separated values (CSV)
HyperText Markup Language (HTML)
text/plain.txtText (generally ASCII or ISO 8859-n)
text/richtext.rtfRich Text Format
Tab-separated values
text/x-component.htcHTML Components
text/x-java-source.javJava Source
text/x-script.hlbHP OpenVMS