Compress files with gzip




















Each data transfer requires some amount of time, largely depending on the size of the transferred files — the more data there is to send, the longer it takes for a page to load in your browser. According to httparchive , the median size of a data transfer like this is around 2, kilobytes, the data equivalent of roughly pages of plain text.

With media-heavy pages, the size can be three to four times larger. How, then, do we keep the internet fast? The solution, as you may guess, is that web servers compress files before sending them to browsers — they turn our page text document into more like a page essay. The reasoning is simple: smaller files mean less work that servers and browsers need to do to transfer them. Compression works well with code like HTML because its syntax is repetitive.

Compression algorithms generally work by finding repeated information in a file and abbreviating it somehow. GZIP is a compression technology frequently used for transferring data quickly over the internet. GZIP is the current standard for file compression on the web.

For now, you just need to know why GZIP is often preferred over similar compression methods. Not bad, except tests comparing compressed file sizes across different compression algorithms have shown that alternative algorithms like Brotli outperform GZIP for text-based assets.

If this is true, why do we still rely so much on GZIP? The main reason is that GZIP tends to be faster than comparable methods. It compresses files in a fraction of the time that other methods take. This speed is crucial for data transfers over the web. Also important is the fact that GZIP compression uses fewer resources than comparable methods.

It requires relatively little computing power and temporary memory space to work. This is key when considering server space and the fact that half of global web traffic is mobile — GZIP is effective for sending web pages to high- and low-powered devices alike.

ZIP is another lossless compression format that is more often used for storing files than transferring them. For a file transfer to work with GZIP, two things must happen. To get maximum compression at the slowest speed run the following command:. You can vary the speed and compression level by picking different numbers between 1 and 9.

The gzip command should not be used when working with standard zip files. You can use the zip command and unzip command for handling those files. Actively scan device characteristics for identification. Use precise geolocation data. Select personalised content. Create a personalised content profile. Measure ad performance. Select basic ads. Create a personalised ads profile.

Select personalised ads. Apply market research to generate audience insights. Measure content performance. Develop and improve products.

List of Partners vendors. By Gary Newell Gary Newell. Reviewed by Chris Selph. Tweet Share Email. Linux Switching from Windows. In This Article. How to Compress a File Using gzip. How to Decompress a File Using the gzip Command. Force a File to Be Compressed. How to Keep the Uncompressed File. Compress Every File in a Folder and Subfolders. Compression is a simple, effective way to save bandwidth and speed up your site. I hesitated when recommending gzip compression when speeding up your javascript because of problems in older browsers.

Most of my traffic comes from modern browsers, and quite frankly, most of my users are fairly tech-savvy. Google and Yahoo use gzip compression. A modern browser is needed to enjoy modern web content and modern web speed — so gzip encoding it is.

Before we start I should explain what content encoding is. The conversation goes a little like this:. Words are repeated throughout the document. If we could send a. The browser-server conversation might look like this:. The HTML portion of the yahoo home page goes from kb to 15kb after compression:. The agreement has two parts. The browser sends a header telling the server it accepts compressed content gzip and deflate are two compression schemes : Accept-Encoding: gzip, deflate.

The server sends a response if the content is actually compressed: Content-Encoding: gzip.



0コメント

  • 1000 / 1000