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:

  1. Type in www.yoursite.com/favicon.ico for the browser URL and press Enter ← where www.yoursite.com is the URL for your app, which could be something like localhost:3000

  2. Press Ctrl+f5

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

Paul is from Perth, Australia, but chooses to live, work and play with his amazing wife and two children in Denver, Colorado. He co-founded and co-leads DDD Denver. Look for him speaking at local user groups, and at regional and international conferences.

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.