How to: Speed up your WordPress site with gzip compression

Enabling gzip compression on your site will dramatically reduce the amount of data sent from your server to the visitors browsers, thus increasing the page-load speed.

The top 3 benefits are:

  • A better user-experience: no one likes to wait 10 seconds for each page to load
  • SEO bonus: search engines too prefer sites that load faster
  • Reduced server load: your server will no longer have to process large requests

How to enable gzip with WordPress?

A few plugins include gzip activation, but my preferred and surefire method is to add a few lines directly to your .htaccess file.

Please, DO KEEP A BACKUP of your .htaccess file before you mess with it!

If you are used to get your hands dirty and manipulate files via FTP, you know how to proceed.
If you would rather stay within your WordPress dashboard, then this free plugin will let you simply edit your .htaccess file through wp-admin: WP Htaccess Editor

A typical WordPress .htaccess file should look like this:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

 

To enable gzip compression, simply add the following at the end of the file:

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddType x-font/otf .otf
AddType x-font/ttf .ttf
AddType x-font/eot .eot
AddType x-font/woff .woff
AddType image/x-icon .ico
AddType image/png .png

 

And that’s it!

You can test the result directly with your browser developer’s tool (inspector), or by using some online tools such as: HTTP Compression Test. Just enter your site’s URL, and it will tell you if it is actually gzipped, and if it is, you will see the impressive compression ratio.

Size reduced by 70,53% with gzip!

Size reduced by 70,53% with gzip!

If you want to know more about gzip compression, how it works and why it’s great, then you will enjoy reading this nicely explained article on betterexplained.com: How To Optimize Your Site With GZIP Compression

Get Our Latest Posts

Subscribe to the blog and get our latest updates delivered right to your inbox.

Warning: we do not send junk, we do not spam and we do not share your email address with anyone!

Connect With Us

Follow us on Google+