There are many things you can and must do to work on your site’s SEO. Here I will share a quick “trick” to quickly boost your SEO with just a simple piece of code you need to add to your .htaccess file.
I will explain the different parts of this .htaccess snippet so you understand what is added. The main thing in these snippets is site speed’s improvement which is also a SEO booster. A quicker site is a happier visitor and a happier bot. By just using these .htaccess snippets you could boost your Google PageSpeed up to 20 points out of a 100!
Expire Headers is another site speed and therefore SEO Booster. Expire Headers are added to tell the browser how often it has to fetch files afresh from the server based on a specific expiry data. And as a lot of static files do not change that often it is good to tell it when to do so. This is especially useful for static files like images.
Cache Control Headers
Cache Control Headers are added to tell the browser how long files should be cached before they should be loaded anew. This is important to make sure it does not reload files too often, but also to make sure it does fetch them anew after a certain amount of time. This is used by most modern browsers instead of Expire Headers and offers more options to control how long browser keep files and fetch anew
# BEGIN Cache-Control Headers <IfModule mod_headers.c> <FilesMatch "\\.(ico|jpe?g|png|gif|swf|gz)$"> Header set Cache-Control "max-age=2592000, public" </FilesMatch> <FilesMatch "\\.(css)$"> Header set Cache-Control "max-age=2592000, public" </FilesMatch> <FilesMatch "\\.(js)$"> Header set Cache-Control "max-age=2592000, private" </FilesMatch> <filesMatch "\\.(html|htm)$"> Header set Cache-Control "max-age=7200, public" </filesMatch> # Disable caching for scripts and other dynamic files <FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$"> Header unset Cache-Control </FilesMatch> </IfModule> # END Cache-Control Headers
Gzip is one technique Apache uses to compress files using one of its modules. By compressing the files they become smaller and are easier to download by the browser. Browsers deal with the decompressing on the fly.
Deflate is just another technique to compress files. Certain Apache servers only use deflate, others only Gzip. That is why we use the ifmodule statement to make sure it only works when the module is available.
Featured Image: Paul Townsend https://flic.kr/p/oqznyf