Do you want to enable GZIP compression in WordPress? GZIP compression will kmake your website faster by doing compression of the data and delivering it to the user’s browsers faster.

A faster website will improve the user experience and if you are running ecommerce website can bring you more sales and conversions.

Please note that the GZIP will not compress your images or other media elements like videos. This problem and solution will be described a bit later in separate article.

Just add some rules to your .htaccess file

If you have a hosting plan, there is a great chance that your hosting provider is running the web server based on apache or compatible solution. Then your WordPress will also already have a .htaccess file generated and present on your server.

By pasting these rules onto the very top of your .hatccess file you can tell the server that You want to have GZIP enabled:

# 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

As you can see the rules are hard to read only at a first glance. Then you will notice that every line consist of the rule which will be applied to the specific file type. Simple right?

Using the plugin – WP Super Cache

x

Author

I’m Michael , a tech geek. Join me on the journey through interwebs to find latest news, tips and hints.

3 Comments

Write A Comment