Can I change a favicon daily

2019-06-17 18:51发布

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?

标签: http favicon
2条回答
放荡不羁爱自由
2楼-- · 2019-06-17 19:05

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'/
查看更多
\"骚年 ilove
3楼-- · 2019-06-17 19:10

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.

查看更多
登录 后发表回答