Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I change a favicon daily

Tags:

http

favicon

I'm working on a calendar app site for internal use here. It's basically a wrapper for a google calendar page, but there will be some extra stuff at the top with the calendar down below. One kind of "fun" thing I'd like to do with this is change up the favicon for the page each day - I'm using a kind of calendar image and I'd like it to show the image for the current day. Is this possible?

I'm using asp.net webforms, but I'm really asking the question at a lower level - is it possible to make this work or will browsers cache it too aggressively?

like image 321
Joel Coehoorn Avatar asked Aug 27 '10 15:08

Joel Coehoorn


1 Answers

In theory, you can. In practice, browsers indeed cache it very agressively. Your best bet is to place the favicon file outside the root folder (to prevent automatic lookup) and manually define it in <head> along with a daily changing timestamp in the query string of the favicon URL. E.g.

<link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico?3213256">

Oh, the HTML page itself should also have less or more the same cache control settings, else the browser will request the page itself from the cache and thus never refresh the favicon.

like image 169
BalusC Avatar answered Sep 21 '22 17:09

BalusC