Weblog

Why is my Favicon not updating or refreshing?

Posted on: January 10th, 2017 | Category: code, Design, PHP, Xhtml/Css

Recently I was asked by a friend why his new and fancy favicon wasn’t showing in his browser. Since I have struggled with this annoying (yet very easy solveable) problem in the past as well, I decided to write the solution down once and for all.

The problem with no updating or refreshing favicons is due to the fact that they are very firmly cached by the browser. Even a hard refresh doesn’t solve the problem.

You can solve this very easyily by making sure there is a unique querystring (?v=x, where x is an unique number) in url to your favicon like this:

<link rel="shortcut icon" href="path/to/favicon.ico?v=2">

Every time you update your favicon, you just add another unique ID in the querystring and the problem should be solved!

If you change your favicon a lot (e.g. during design/development process) you can also automate this. This PHP example generates a unique ID every time.

<link rel="shortcut icon" href="path/to/favicon.ico?v=<?php echo uniqid(); ?>"> 

Comments

Leave your own comment »

Leave a Reply

Keep it polite and on-topic please.

The Fine print™: By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution.
Your email is never published nor shared. Required fields are marked *