Explore the Power of GA4 in WooRank’s Reports.

Want to Reduce Your Pages' File Size by 90%?

When you try to load a web page, there are a few steps that have to take place:

  1. Your browser sends a request to the site 's server
  2. The server finds the page and sends it to your browser
  3. Your browser downloads  the page and displays it on your screen

Since web users are impatient, reducing the time each step takes will help you realize major benefits in your user experience and SEO performance.

Where you run into problems is when the size of your page "with all of its images, CSS, JavaScript and other files" starts to get so big it slows down that third step.

Fortunately, there 's a way you can configure files on your server that can reduce their sizes by up to 90%, which means it takes less time for a browser to start showing the page to a user.

This is accomplished by enabling compression on your server and sending zipped versions of files to users ' browsers. These zipped files are much smaller in size than the normal version, so transfer takes much, much less time.

The users ' browsers are able to download, unpack and display these files quickly.

In this guide, you'll learn...

What is Compression?

 Compression is the process by which files on a server are encoded to take up less space, making them easier and faster to send. On a technical level, compression works by scanning a file, finding repetitive data and replacing duplicates with a unique identifier that takes up less space than the original data. When a file is uncompressed, those unique identifiers are replaced with the original data.

There are lots of different formats for compression files, but not all browsers will necessarily support a given format. Except for one.

Gzip.

All modern browsers are able to automatically receive and handle files compressed using the gzip format. So you don 't have to worry about any users being unable to properly load any files.

Why Does Compression Matter in SEO?

Compression matters for SEO because speed matters in SEO. Web users don 't like waiting for pages to load (as we 've discussed), so Google isn 't really interested in recommending slow pages to their users.

As such, how quickly Google is able to connect to your site and access content and information to a user has a direct impact on rankings.

How to Enable Compression

How you enable compression on your server depends on your server. Here, we 'll go over the most common ways of enabling compression for various servers.

Enabling compression via .htaccess

For most people, enabling compression means adding code to their .htaccess on their server. If you 've got WordPress, you can use a plugin to edit this file. Otherwise, you can use your file manager for this.

Add this code to your .htaccess file to enable GZIP compression:

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

Then save your file and refresh your page.

Enabling compression on Apache servers

The above method used work with Apache webservers. However, new Apache servers now use a method called deflate.

To use it, delete the code you added above and replace it with this:

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

The benefit of using deflate over gzip is that deflate works automatically with Apache servers while gzip has to be installed first. However, gzip does compress files more than deflate, so if you have a lot of images or larger files, it 's probably worth your time.

Enabling compression on NGINX servers

To enable gzip compression on an NGINX server, open the main Nginx configuration file in your preferred text editor. Find the gzip settings section in the file. This section looks like this:

##
# undefined Settings
#
#
gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

By default, gzip compression is enabled (you can see this with the gzip on directive). However, you 'll see that lots of settings have been commented out by putting the # at the start of the line. To optimize your gzip compression, you 'll want to uncomment these settings and then add some more.

To this code, we 'll add

  • The gzip_min_length 256; line. This tells Nginx not to compress any files smaller than 256 bytes. Files this small won 't see much benefit from gzip.
  • To the gzip_types line at the bottom, add additional file types application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon. This will allow compression for web fonts, icons and SVG images.

After you 're all said and done, your gzip settings should look like this:

##
# undefined Settings
#
#
gzip on;
gzip_disable "msie6";

gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;

Now save and close your file. Enable all your changes by restarting Nginx.

Testing Your Compression

Once you 've added whichever bit of code applies to your server, you should test it. Running a WooRank Review of your site will test whether or not your files are being compressed.

You can also use Google 's PageSpeed Insights tool to test for uncompressed files.