开发者

Can I change a favicon daily

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?


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.


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://example.com/favicon-20100827.ico' rel='shortcut icon'/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜