What do you do when you’ve updated the
favicon.ico file on your server, but your browser is still showing the old one? It’s probably browser caching issue, so if you need to do a local refresh, look no further (see below if it’s actually a server issue). This post will teach you how to force a favicon refresh, using a technique that works locally and doesn’t require code changes.
This is based on one of the answers to the Stack Overflow question How do I force a favicon refresh? Last time I had to do this for a Rails app my Google-fu was apparentely too week to find the answer, so I’m posting the solution for next time I have to do it.
Once you’ve updated
favicon.ico, which lives in
/public for a Rails app, the two simple steps are:
www.yoursite.com/favicon.icofor the browser URL and press Enter ← where
www.yoursite.comis the URL for your app, which could be something like
Now when you navigate to the URL for your website the
favicon.ico icon which shows in the browser tab should be the new one. Works for me!
You should be able to force browsers to download a new version using the link tag and a querystring on your filename, such as:
<link rel="shortcut icon" href="http://www.yoursite.com/favicon.ico?v=2" />
This is especially helpful in production environments to make sure your users get the update. If this still doesn’t work, you might want to look at context expiration of some kind. You may still need to use the technique above to get your local browser to update though.
About the Author
If you are looking for an expert hands-on team coach and design mentor in Domain-Driven Design (DDD), BDD with Cucumber, or lean/agile process Paul is available for consulting and training through his company, Virtual Genius LLC.