WP Hosting Blog

Best practice WordPress hosting, development and management

2018-10-15T10:17:36+00:00 October 15th, 2018|WordPress Hosting & Development|By WP Hosting Editor|

Speed Up Your WordPress Website With Gzip compression

Gzip compression is a quick and effective way to speed up your page load times, leveraging web browser’s ability to compress and decompress data.

GZip lowers the amount of bandwidth that is needed to transfer your sites files from your hosting service to your site’s users, reducing the time taken to load up your site by a considerable amount.

In most cases, modern web hosting company’s support this feature already, however some configuration is likely required in order to utilize Gzip with your website.

For WordPress based websites, there are a number of different plugins you can use to do this, and we will cover a couple of them below.

WP Super Cache

If you are using WP Super Cache on your WordPress website, Gzip compression can be easily enabled under “Advanced” within your WP Super Cache settings by checking the box next to “Compress pages so they’re served more quickly to visitors” and then clicking on ‘Save’.

For more information configuring this plugin take a look at our KB article, Configure WordPress with WP SuperCache.

W3 Total Cache

If W3 Total Cache is your plugin of choice for your WordPress website, GZip Compression can be enabled within your “Browser Cache” settings which can be found by clicking on the “Performance” tab from your WordPress admin dashboard.

Once on the “Browser Cache” settings page, simply check the box next to “Enable HTTP (gzip) compression” and then save your settings.

You may also be interested to learn more about this plugin in our interview with its creator: W3 Total Cache: Interview with Frederick Townes.

WP Rocket

WP Rocket, which is a premium (paid) performance optimization plugin, comes with gZip compression built in and it sets it up when the plugin is activated.

Modifying your .htaccess file. (Advanced users only)

For more advanced users, gZip compression can be activated by adding 30 lines of code to your site’s .htaccess file.  This file generally resides within the public_html or www folder on your sites hosting service, dotfiles are generally hidden so you will need to ensure that you can view these if you are using your cPanel’s ‘File Manager’ or ‘FileZilla’.

To show hidden files within cPanel’s File Manager;

1.  Once in your ‘File Manager’ within cPnael, click on the settings button (usually at the top right)

2.  Check the box beside “Show Hidden Files (dotfiles)”

3.  Click “Save”

Once you have found your .htaccess file, you will need to add the following code to it (credit to GTmetrix for the code snippet)

# 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

Find out more: read WP Rocket Review: The Professional WordPress Caching Plugin.

Check that Gzip is doing its job

Once set up, you can check your WordPress websites gZip compression status by visiting checkgzipcompression.com, some users have reported that gZip has decreased the bandwidth requirements and page load times by up to 70%, in the test conducted in the screenshot below, we saved almost 60%.

Leave A Comment