What is GZIP Compression?
When a user hits your website a call is made to your server to deliver the requested files. The bigger these files are the longer to take appear on the browser screen.
GZIP compression compresses your webpages and style sheets before sending them over to the browser. This reduces transfer time since the files are much smaller.
GZIP compression can be enabled for your website and saves at least 50% of your bandwidth usage.
How does it work?
GZIP is a fairly simple idea that is extremely powerful when put to good use. Gizp locates similar strings within a text file and replaces those strings temporarily to make the overall file size smaller.
The reason gzip works so well in a web environment is because CSS files and HTML files use a lot of repeated text and have loads of whitespace. Since gzip compresses common strings, this can reduce the size of pages and style sheets by up to 70%!
How to enable:
For Apache:
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>
For IIS
If your server is IIS, follow these instructions in the Microsoft TechNet document to enable compression.
How to enable GZIP Compression in .htaccess
Reviewed by Snehal Vasava
on
May 22, 2018
Rating:
Reviewed by Snehal Vasava
on
May 22, 2018
Rating:

No comments: