htaccess – Cache Your Favicon to Speed Up Your Site

Send Us a Sign! (Contact Us!)
--> (Word) --> (PDF) --> (Epub) --> (Text)
--> (XML) --> (OpenOffice) --> (XPS)

Learn how to cache the favicon on your web site to reduce the number of HTTP requests, speed up your site, and lessen your server load. Every time someone loads a page from your Mambo site the favicon is requested.

When search [gs bot]s visit your site they can generate a lot of traffic with calls to the favicon. Here's how to do something about this:

  • Check that your server is running Apache.
  • Check that your server is running mod_headers (most are)
  • Check that you can use an .htaccess file (if you are using the inbuilt Mambo SEF then you are already using .htaccess)

If all these are in place, then add this directive to your .htaccess file.

<FilesMatch "\.ico$">
Header set Expires "expiryDate"

You can set the expiryDate to any date in the future that you want. So, for example, if you plan to have your site online for several years and don't think you will change your favicon for a long time, then this may be appropriate: "Mon, 20 Apr 2015 23:30:00 GMT".

Here's the completed directive:

<FilesMatch "\.ico$">
Header set Expires "Mon, 20 Apr 2015 23:30:00 GMT"