Setting up Server Side Caching to Boost SEO

By now you’ve probably done tests on Woorank or Seositecheckup, and have seen that that your site could benefit from server side caching, or have the browser cache the static content from your website. What does that mean? Basically instead of your browser reloading every asset (image, font, css, etc) every load, we can tell the browser to cache this content for a certain amount of time because these do not change often. This greatly reduces load time, thus improving your overall SEO.

So how do we do this?

If you are using GoDaddy, Host Gator, or anything like that, it is actually very easy. Just skip to the bottom section named “Setting up .htaccess”.

Apache Setup

Make sure you have Apache set up.

First run:

sudo a2enmod mod_expires

This enables the mod_expires module for apache.

Next, run this:

nano /etc/apache2/apache2.conf

NOTE: If you are not running Ubuntu, switch apache2 with httpd.

Find the Directory block in the file.

Below that block, paste this and replace the path to your web root:

<Directory /YOUR/PATH/HERE>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all

Restart Apache

sudo service apache2 restart

Setting up .htaccess

In the root of your web directory (where your index.html, index.php, etc is) create a file named .htaccess. Don’t forget the “.” in front of the file name.

Paste the following content into it:

ExpiresActive on

ExpiresByType image/png "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType font/woff "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresDefault "access plus 1 month"

And just like that you have enabled server-side caching!