How to use GZIP for webpage

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
Loaded Modules:
...
deflate_module (static)
...
Syntax OK


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

<Location />
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4\.0[678] 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
</Location>

 

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 . . .

你可能感兴趣的:(apache,html,Web,Flash)