tags:

views:

55

answers:

2

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?

+5  A: 

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.

BalusC
Good idea, forcing a unique path is a good way to bust out of the cache problem +1
Konrad
Hmm... that 3213256 seems longer than necessary. I bet I could get away with re-using 1-31.
Joel Coehoorn
That was just an example :) It doesn't matter what you put in, as long as it changes daily.
BalusC
A: 

You should be able to control how the favicon is cached by setting the expires header. Alternatively, just change the URL to the favicon daily and set it using the link header.

<link href='http://yoursite.com/favicon-20100827.ico' rel='shortcut icon'/
Mr. Shiny and New