Speed Up Your Website Using GzipLast Updated on
Browser v/s Server – Optimizing Site Using GZIP Compression
In the online world if ever a browser and server interacted in a chat environment, this is what would definitely come up:
Browser: Can you please give me index.html? I won’t mind a compressed version if you can provide that.
Server: I am searching for the file… yes I find it. Wow! You will accept the compressed version That is Amazing. I am zipping it and sending it over.
Browser: Great! It’s only 25 Kb. I’ll unzip it and show it to the user.
Even though the above interaction sounds pretty amusing but this is how it can happen and the pages on internet can now open in a flash. Mod GZIP can compress all outgoing HTML and the browser in return un-compresses the HTML thereby displaying them at faster speeds.
Sometimes issues between browser and proxies can cause a severe mismatch and modules in Apache provide a work around by adding relevant response headers automatically. Servers decide what to gzip based on the file type, for example images and PDF files should not be gzipped because they are already available in a compressed form.
The GZIP compression is therefore an excellent way to reduce the server response time. Through the GZIP compression the response is generally reduced by about 70%. Many popular browsers of today support the GZIP compression.
Here is how you can enable GZIP compression on an Apache server:
1. Make sure you have the deflate module enabled, you can verify this by typing
# /usr/local/apache2/bin/apachectl -t -D DUMP_MODULES
2. If you do not have deflate_module then recompile the apache web server to set it on.
3. Add the following code to your Apache conf file
BrowserMatch ^Mozilla/4\.0 no-gzip\
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don’t compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
Note: The line in bold which goes like.. “no-gzip dont-vary” tells your Apache server to not compress certain type of files.
This is all you need to do to enable GZIP compression.
We hope this benefits you.
Watch out for more . . .
Disha is a freelance blogger and email marketer. She writes extensively about WordPress, SMEs, online marketing and nonprofits.