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’re sent to browsers, gzip compression ensures faster page rendering and downloads for your users.

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

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 > Edge Application.
  2. Click on the application you want to configure.
  3. In the Rules Engine tab, click the + Rule button.
  4. Give your rule a name and, if necessary, a description.
  5. Select either Response Phase or Request Phase.
  6. 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 /
  7. In the Behavior section, select the Enable gzip behavior.
  8. 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.


Support for gzip compression

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

About MIME types

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

MIME TypeExtensionDocument type
application/eot.eotMS Embedded OpenType fonts
application/fontOpenType font
application/font-sfnt.ttf
.otf
SFNT format
application/font-woff.woffWeb Open Font Format (WOFF)
application/font-woff2.woff2Web Open Font Format 2 (WOFF2)
application/javascript.jsJavaScript
application/json.jsonJSON format
application/ld+json.jsonldJSON-LD format
application/opentype.otf
.otc
.ttf
.ttc
OpenType
application/otf.otfOpenType
application/truetype.ttf
.tte
TrueType
application/ttf.ttfTrueType
application/vnd.ms-fontobject.eotMS Embedded OpenType fonts
application/x-font-opentype.otfOpenType
application/x-font-truetype.ttfTrueType
application/x-font-ttf.ttc
.ttf
TrueType
application/x-httpd-cgi.pl
.sh
.cgi
CGI scripts/programs
application/x-javascript.jsJavaScript
application/x-mpegurl.M3U8iPhone Index
application/x-opentype.ttcOpenType font
application/x-otf.otfOpenType font
application/x-perl.plx
.pl
.pm
.xs
.t
.pod
Perl script
application/x-ttf.ttfTrueType
application/xhtml+xml.xhtmlXHTML
application/xml+rss.rss
.xml
RSS, Atom and XML
font/eot.eotEmbedded Open Type
font/opentypeotf
.otc
.ttf
.ttc
OpenType font
font/otf.otfOpenType font
font/ttf.ttfTrueType font
image/svg+xml.svgScalable Vector Graphics (SVG)
image/x-icon.icoICO
text/css.cssCascading Style Sheets (CSS)
text/csv.csvComma-separated values (CSV)
text/html.htm
.html
HyperText Markup Language (HTML)
text/javascript.jsJavaScript
text/js.jsJavaScript
text/plain.txtText (generally ASCII or ISO 8859-n)
text/richtext.rtfRich Text Format
text/tab-separated-values.tsv
.tab
Tab-separated values
text/x-component.htcHTML Components
text/x-java-source.javJava Source
text/x-markdown.mdMarkdown
text/x-script.hlbHP OpenVMS
text/xml
application/xml
.xmlXML

Contributors