Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gzip or not gzip

Tags:

php

gzip

I keep hearing that gzip your site is a good practice to speed-up delivery. My site has a very vast load in general, shall i still look into gzip? I also read about disadvantages of using gzip, such as time required to unzip contents for the browser to display. Is it true?


UPDATE:

This question is based on the assumption that the site is fairly optimized already.

Actually I optimized it already. Most of the content on my site is db driven and originally it took some time to load it all, so what I did, I wrote a few scripts that run nightly, generate content and store it as static HTML files that are included on the heaviest trafficked pages. The load on the server is way below its capacity, so, thank you for that insight, I will consider it more seriously now. I was thinking of using some PHP class that does it dynamically. Do you have any recommendations?

like image 420
santa Avatar asked Oct 12 '10 14:10

santa


People also ask

When should you not use gzip?

If you take a file that is 1300 bytes and compress it to 800 bytes, it's still transmitted in that same 1500 byte packet regardless, so you've gained nothing. That being the case, you should restrict the gzip compression to files with a size greater than a single packet, 1400 bytes (1.4KB) is a safe value.

Should I use gzip?

You should gzip your content because: it easy very easy to do. it saves you bandwidth(which could save you money). it will make your site faster.

Is not gzip format?

The error “gzip: stdin: not in gzip format” occurs when the file is not in the gzip format. There are two cases; either the file is only archived and renamed with the “. gz” extension or the file is in some other format. The gzip is used to zip, compress, or decompress the files.

Should I gzip images?

Don't use gzip for image or other binary files Image file formats supported by the web, as well as videos, PDFs and other binary formats, are already compressed; using gzip on them won't provide any additional benefit, and can actually make them larger.


1 Answers

Compressing your response will help with transfer times. That means it will decrease the time it will take for the user to download the generated page. It will not (in general) reduce the load on your server. In fact, it can increase it slightly since compression itself is not free (it eats up some CPU cycles).

Typically, there's no disadvantage from a user experience (only advantages).

However, if your server is already heavily loaded, I'd probably skip it since it will only add to that load (in general). Optimize the code first, then add compression. Don't try to add compression as a band-aid for poorly optimized code (it won't work)...

like image 99
ircmaxell Avatar answered Oct 01 '22 04:10

ircmaxell