double-xx-design-official-logo-text-only
check-gzip-compression

Enable Gzip Compression without Plugin

Hi Guys

I thought I’d take a minute to explain just exactly how to enable Gzip compression on an Apache server without a plugin.

What is GZIP Compression?

GZIP is a type of file format as well as a software application used for file compression and decompression. It is enabled server-side, and allows for further reduction in the size of your HTML, stylesheets, and JavaScript files.

GZip will NOT work on images as these are already compressed in a different way. Some people have seen up to 70% reductions due to compressing their sites and It’s also probably one of the easiest optimizations you could make when it comes to WordPress.

When a web browser like Chrome or Firefox fetches a website it first checks to see if the web server has GZIP enabled. It does this by checking if the “content-encoding: gzip” response header exists and if the header is detected, it serves up the compressed and smaller files.

If not, the browser will serve the uncompressed files instead. Not having GZIP enabled, will most likely cause you to see warnings and errors in speed testing tools such as Google PageSpeed Insights and GTmetrix.

Chances are, that if a speed-test states that Gzip compression is not enabled… well, it probably isn’t… or, it just hasn’t been implemented correctly… so let’s fix that.

Enable GZIP on Apache:

Although there are plugin’s that can do this… I solely recommend enabling Gzip compression by editing your .htaccess file. Most shared hosts use the Apache server management system, in which you can simply add the code below to your .htaccess file. You can find your .htaccess file at the root of your WordPress site via your File Manager(usually “/public”).

NB: Ensure mod_filter is loaded on your server, otherwise the AddOutputFilterByType directive will not work and could cause a 500 error. We strongly recommend checking your error logs inside WordPress to see if you have any issues with the code below.

<IfModule mod_deflate.c>
# 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
</IfModule>

Now here’s the trick…

Finally, you need to ensure that you add the code below the current contents of your .htaccess file. So, after the line that say’s # END WORDPRESS

And that’s it!!

Hopefully I gave you some insight into speeding up your site and I will try to do more of these as I am able to… Please let me know if you have any questions and I’ll try my best to assist.

If you’d like to have a site built, please get in touch and lets give your brand the look it deserves.

You can also have a look at our Portfolio page for more website & design examples.

Have an awesome day everyone!

~dxxd
admin@dxxd.bid

Leave a Comment

Your email address will not be published. Required fields are marked *


Scroll to Top