May 13, 2016
Despite the proliferation of high-speed Internet, bandwidth usage is a huge concern for service providers and end users. For large web services, having to deliver hundreds or even thousands of large files can have a big impact on performance.
Compression helps resolve this issue by reducing the file size of the content before it leaves the server. GZIP, the most popular compression method, is used by web servers and web browsers to seamlessly compress and decompress content as it’s transmitted.
How GZIP Works
GZIP acts as both a file format and an application.
- When a server receives a request for a web page, the server checks the header of the request to determine if the browser supports GZIP.
- If so, the server generates the markup for the page before applying GZIP.
- GZIP converts the markup into a compressed data stream, which is then delivered to the end user.
- When the end user receives the compressed stream, their browser decompress it.
Most modern web browsers support GZIP decompression and will include this as part of their request header. The compressed stream is decompressed to the original markup, which is then rendered to the user’s browser.GZIP can also be used to compress files before they’re requested.
In most cases, GZIP compression is performed on-the-fly, which makes it easier for dynamic websites to deliver realtime content at the expense of higher resource usage. Since this content frequently changes, it would be a waste to compress it before it’s needed. For static content, however, files can be compressed in advanced, allowing service providers to benefit from lower bandwidth costs without the additional overhead of ongoing compression.
How Compression Levels Affect Resource Usage
Compression is a CPU-dependent process, with higher compression levels resulting in smaller files at the expense of CPU. Enterprises can choose how much to compress – as well as what to compress – based on the needs of their web service. Some providers may choose to only compress HTML, while other providers may choose to compress everything.
Example of GZIP
A 2009 study shows the drastic impact compression can have on some of the world’s top websites. For Facebook, enabling compression reduced the page load time by an average of 9.4 seconds, or 414%. A savings of 350 KB may not seem like much in today’s data driven world, but when aggregated across all of Facebook’s users it makes for a substantial improvement.
Benefits of GZIP
GZIP is a key strategy for delivering content faster while reducing network traffic.
- Enterprises experience lower bandwidth costs since smaller files are being sent over the network. A slight bump in CPU use could lead to a big drop in bandwidth usage.
- Users experience faster page load times as less data is transferred to and from their devices. Now wsers with data caps are able to stretch their monthly allowance even further.
Over the past 10 years, the average web page has grown in size by almost 1.2 MB. As our demand for information increases, techniques for quickly and efficiently delivering large amounts of data are becoming more and more relevant.
When a 100ms increase in load time can reduce your sales by 1%, it’s vital to make web services as efficient as possible. GZIP compression can add a profitable speed boost any web service.