Speed Up WordPress Sites With Compression

by | WordPress

Turning on compression for webservers will help speed up WordPress sites by sending less data over the network.  Google’s PageSpeed Insights also likes compression when evaluating the speed of websites.  It’s easy and very quick to do; however, make sure a backup of the .htaccess file in the top level directory is made before doing this.  You’ve been warned.  If things go afoul, just copy the backup .htaccess file to restore your settings.

This trick works with Apache web servers.  Add the following lines of code to the end of the .htaccess 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
AddType image/svg .svg

There are also several WordPress plugins available that will auto-magically setup compression on sites.  In the “add new plugin” function, search on keywords “gzip compression” to locate them.