Learn how to enable Gzip compression and how it helps to improve page speed. Gzip compression is a simple method to retrieve data fast, save bandwidth and speed up page load times.
Most of the recent browsers support Gzip compression. When you enable Gzip compression, all the web pages and style sheets gets compressed before sending them to the browser. The user’s browser unzips the files and shows the information.
It reduces the size of the page, so it transfers files fast from server to browser. Gzip compression is one of the best page speed optimization technique.
Enabling Gzip compression is great for improving page speed because the browser of your visitor will need to download mush smaller web files as the original ones when browsing your website.
Most of the cases your website uses CSS and HTML files. Instead of loading those large files directly, use GZip compression along with leverage browser cache of the user. The first one helps to transfer files fast because compressed and second one helps to store repeated files in user’s browser until some interval of time.
When the browser visits a web server it checks your server weather enabled for Gzip or not. If it is Gzip enabled, it receives the Gzip file which is significantly smaller in size.
How to enable Gzip compression?
Based on the web server use the settings for Gzip compression changes. Here is the simple code for Apache web server, place code at the bottom of .htaccess file which is in the root directory (mostly public_html) of your website server.
There are two modes to enable Gzip compression for Apache servers one is mod_zip and second one is mod_deflate. There is no performance difference but the recommended one is Mod_deflate method to compress the output from the server.
Step by step procedure to enable Gzip compression:
1) Download the .htaccess file using any FTP client and add the code at the bottom of the file and save. (keep backup of .htaccess file before modifying.)
mod_deflate method( recommended):
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/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/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 no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
mod_gzip method:( alternate method)
note: use only if mod_deflate method not working, but don’t use both.
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_include handler ^cgi-script$
2) Delete existing .htaccess file from the root folder.
3) Upload the modified .htaccess file to the root folder.
if you are using windows servers you can configure HTTP compression (llS 7). you can have feature to compress both static files and dynamic application responses.follow Microsoft technet document to enable Gzip compression for windows servers.
yes it will definitely improves the page speed
Comments are closed.