Enable Gzip Compression – In this tutorial we will discuss how to enable Gzip Compression feature on your web server so that it can increase the speed of your website. There are two ways to activate Gzip Compression by configuring the cpanel or changing the .htaccess file.
What is Gzip Compression
There are several benefits obtained by activating Gzip Compression.
Advantage Enable Gzip Comppression
- Preferred by search engines.
- Your server no longer has a large request to process.
- The size of your website will be reduced by 70-90%.
- Increase the load speed of your website.
How it Works?
Gzip is actually a fairly simple idea that is very powerful when used properly. Gzip places the same string in a text file and replaces the string temporarily to make the whole file size smaller.
The reason gzip works well in a web environment is because CSS files and HTML files use a lot of repetitive text and have lots of spaces. Because gzip compresses common strings, it can reduce page size and style sheets to 70-90%!
When the browser visits the web server, the browser will check and see if the server has activated the gzip compression method and then asks for a web page. If gzip is activated, the browser will receive a smaller gzip file and if gzip is not activated the browser will receive a much larger file.
How to Enable Gzip Compression
Make sure the mod_deflate module is active on your server then paste or add the script below to your .htaccess file
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
For cPanel users, you can activate it through the menu in cPanel. Next is how to activate Gzip Compression on your Cpanel:
- Login to your cPanel
- Navigate to “Optimize Website”
- Chose Compress all content and click Update Settings.
Insert or add the script below to your .htaccess file
gzip_buffers 16 8k;
# Disable for IE < 6 because there are some known problems
gzip_disable "MSIE [1-6].(?!.*SV1)";
# Add a vary header for downstream proxies to avoid sending cached gzipped files to IE6
After enable Gzip Compression you need to check whether Gzip Compression is enable or not, to check it, you can use online tools bellow:
That’s it, hope you can get it all running without a problem, and enjoy your webiste speed.
By the way, don’t forget to subscribe my blog. It should giving you much information.