Changed Your Favicon and the Tab Still Shows the Old One? I Tested Chrome's Favicon Cache in 8 Scenarios
You replace favicon.svg, deploy, press F5, and the old icon is still in the tab. Then you open a...
You replace favicon.svg, deploy, press F5, and the old icon is still in the tab. Then you open a private window and the new one is there. So the deploy worked, and your own browser is holding on to the old file. The real question is whether your visitors' browsers are doing the same, and for how long.
I wanted an answer from a test instead of from forum threads, so I built a small one. A local server serves a page with a solid red 16×16 SVG icon. Real Google Chrome 156 (headful, on a virtual display) opens the page. Then the server starts serving a blue icon at the same URL, and I do one ordinary thing after another: reload, click to another page, open a new tab, hard reload, restart the browser. After each step I record two things: which icon requests reached the server, and which colour Chrome actually drew in the tab (read from a screenshot of the tab strip).
The short version: the icon's URL matters more than its cache header. If you change the file but keep the URL, most visitors keep the old icon until something forces a fetch. If you change the URL, the next page view shows the new icon.
The test setup
The server is about 20 lines of Python. Pages are never cached (no-store), so every navigation gets fresh HTML. Only the icon's Cache-Control changes between scenarios. It also logs every icon request, including whether it was conditional (If-None-Match), so a revalidation would show up as a 304.
class H(http.server.BaseHTTPRequestHandler):
def do_GET(self):
p = self.path
if p.startswith('/page'):
link = f'<link rel="icon" href="{S["href"]}">' if S['href'] else ''
b = f'<!doctype html><title>shop</title>{link}<body><h1>{p}</h1>'.encode()
self.send_response(200); self.send_header('Content-Type', 'text/html')
self.send_header('Cache-Control', 'no-store'); self.end_headers(); self.wfile.write(b); return
if p.startswith('/icon.svg') or p.startswith('/favicon.ico'):
body = svg(S['color']); etag = '"' + hashlib.md5(body).hexdigest()[:10] + '"'
inm = self.headers.get('If-None-Match')
status = 304 if inm == etag else 200
S['log'].append({'path': p, 'status': status, 'cond': bool(inm)})
self.send_response(status); self.send_header('Content-Type', 'image/svg+xml')
self.send_header('Cache-Control', S['cache']); self.send_header('ETag', etag)
self.end_headers()
if status == 200: self.wfile.write(body)
Chrome is driven by Playwright with a persistent profile, so the browser keeps its disk cache and its own favicon store between restarts, as a normal browser would. A "hard reload" is Chrome's reload with the cache ignored, the same thing Ctrl+Shift+R does. Each step waits 4 seconds before the screenshot.
Scenario A: same URL, cached for a day
This is the most common setup: <link rel="icon" href="/icon.svg"> with Cache-Control: max-age=86400.
1 first visit (icon is red) server=red tab=red | /icon.svg 200
-- icon file on the server is now BLUE
2 reload (F5) server=blue tab=red | no icon request
3 click a link to another page server=blue tab=red | no icon request
4 same page in a new tab server=blue tab=red | no icon request
5 hard reload (Ctrl+Shift+R) server=blue tab=blue | /icon.svg 200
6 restart Chrome, open the page again server=blue tab=blue | no icon request
Three ordinary actions after the change sent no icon request at all. The tab stayed red. Only the hard reload asked the server again, and after that the blue icon stuck, even across a restart.
That's the "I uploaded it and nothing changed" experience. Your visitors won't hard-reload your site to see a new favicon.
Scenario B: same URL, no-cache
The usual advice is "send no-cache so the browser checks every time". So I did:
1 first visit (icon is red) server=red tab=red | /icon.svg 200
-- icon file on the server is now BLUE
2 reload (F5) server=blue tab=blue | /icon.svg 200
3 click a link to another page server=blue tab=blue | no icon request
4 same page in a new tab server=blue tab=blue | no icon request
5 hard reload (Ctrl+Shift+R) server=blue tab=blue | /icon.svg 200
6 restart Chrome, open the page again server=blue tab=blue | no icon request
This looks fixed: a normal reload fetched the new icon. Two details are worth noticing, though. Steps 3, 4 and 6 sent no request even though the header says "check every time". And the reload fetch was a plain request with no If-None-Match, so it came back as a full 200, not a 304, even though the server sends an ETag.
So I ran the order a visitor is more likely to follow: the icon changes, they don't reload, they just come back later.
== G: no-cache, then restart Chrome
1 first visit (icon is red) server=red tab=red | /icon.svg 200
-- icon file on the server is now BLUE
2 restart Chrome, open the page server=blue tab=red | no icon request
3 reload (F5) server=blue tab=blue | /icon.svg 200
4 restart Chrome again, open the page server=blue tab=blue | no icon request
After a full browser restart, Chrome opened the page with the old red icon and didn't ask the server, despite no-cache. Only a reload fetched the new one.
My reading of all three runs: Chrome remembers which icon belongs to which page in its own favicon store, separate from the normal HTTP cache. On a plain navigation it uses what it has. A reload makes it fetch the icon again, and that fetch goes through the HTTP cache, so max-age decides whether the request reaches your server. That explains every row above. It's still an interpretation of what I saw, not something I read in Chrome's source.
Scenario E and F: restarts and short caches
Two more checks. E: a day-long cache and a visitor who only restarts the browser. F: a cache of only 10 seconds.
== E: day-long cache, visitor only restarts Chrome
1 first visit (icon is red) server=red tab=red | /icon.svg 200
-- icon file on the server is now BLUE
2 restart Chrome, open the page server=blue tab=red | no icon request
3 reload (F5) server=blue tab=red | no icon request
4 restart Chrome again, open the page server=blue tab=red | no icon request
== F: cache of only 10 seconds
1 first visit (icon is red) server=red tab=red | /icon.svg 200
-- icon file on the server is now BLUE
2 reload right away server=blue tab=red | no icon request
3 wait 15 s, then reload server=blue tab=blue | /icon.svg 200
4 wait 15 s, click to another page server=blue tab=blue | no icon request
5 restart Chrome, open the page server=blue tab=blue | no icon request
With a day-long cache, restarting doesn't help: the old icon survived two restarts and a reload. With a 10-second cache, a reload after it expired fetched the new icon. But in both runs the reload was the step that made the difference. A visitor who only clicks around your site never triggers it.
Scenario C and H: change the URL instead
Now the same change, but the page links /icon.svg?v=2 after the swap instead of /icon.svg?v=1. The icon itself gets a very long cache this time (max-age=31536000, immutable), because a versioned URL never needs to change.
== C: versioned URL (?v=2 after the change), reloads
1 first visit (icon is red) server=red tab=red | /icon.svg?v=1 200
-- icon file on the server is now BLUE, page now links /icon.svg?v=2
2 reload (F5) server=blue tab=blue | /icon.svg?v=2 200
...
6 restart Chrome, open the page again server=blue tab=blue | no icon request
== H: versioned URL, no reload
1 first visit (icon is red) server=red tab=red | /icon.svg?v=1 200
-- icon is now BLUE, pages now link /icon.svg?v=2
2 click a link to another page server=blue tab=blue | /icon.svg?v=2 200
3 restart Chrome, open the first page server=blue tab=blue | no icon request
The new URL was fetched on the next page view, with no reload, and the new icon stayed after a restart. A URL Chrome has never seen can't be answered from any cache, so it has to ask. This was the only setup in which the change reached the visitor without any special action.
Scenario D: the default /favicon.ico
Sites with no <link rel="icon"> get the browser's automatic request for /favicon.ico. It behaved exactly like Scenario A: no request after the change on reload, navigation or a new tab; only the hard reload fetched it. And you can't version an automatic request, so if you ever plan to change the icon, add a <link> tag.
All eight scenarios in one table
| Scenario | Icon cache header | Old icon after a plain reload? | Old icon after a new page or tab? | Old icon after a restart? |
|---|---|---|---|---|
| A same URL | max-age=86400 | yes | yes | only until a hard reload |
| B same URL | no-cache | no | no (after the reload) | no (after the reload) |
| G same URL, no reload first | no-cache | n/a | n/a | yes |
| E same URL, restarts only | max-age=86400 | yes | n/a | yes, twice |
| F same URL | max-age=10 | until it expired | no (after the reload) | no |
| C versioned URL | 1 year, immutable | no | no | no |
| H versioned URL, no reload | 1 year, immutable | n/a | no, new on the next page | no |
| D /favicon.ico, no link | max-age=86400 | yes | yes | only until a hard reload |
What to do when you change a favicon
- Change the URL, not just the file. Add a version (
/favicon.svg?v=2) or put a content hash in the filename (favicon.3f9a.svg). Update every<link rel="icon">,apple-touch-iconand manifest entry that points to it. - Then give the icon a long cache. Once the URL changes with the content,
max-age=31536000, immutableis safe and saves a request on every visit. - Don't count on
no-cachealone. In my test it fixed reloads, but a visitor who restarted the browser and came back still saw the old icon. - Keep the HTML itself uncached or short-lived. The new URL only helps once the visitor gets HTML that contains it.
- Check your own browser with a hard reload or a fresh profile. A plain F5 may just show you your own cache.
The same rules apply to an emoji favicon from a URL
If you use a hosted icon such as EmojiFavicons, the icon URL is the emoji itself: <link rel="icon" href="https://emojifavicons.com/rocket">. I checked the response headers:
## https://emojifavicons.com/rocket
content-type: image/svg+xml
cache-control: public, max-age=86400, s-maxage=604800
bytes=144 sha1=4d0688c653cb
## https://emojifavicons.com/rocket?v=2
cache-control: public, max-age=86400, s-maxage=604800
bytes=144 sha1=4d0688c653cb
## https://emojifavicons.com/fire
cache-control: public, max-age=86400, s-maxage=604800
bytes=144 sha1=62bf7fd4635b
## https://emojifavicons.com/rocket?bg=ffd700&shape=circle
cache-control: public, max-age=3600
bytes=199 sha1=63430d658905
The plain icon tells browsers to keep it for 24 hours, which matches the "browser 24 hours" note in the API docs. Two practical consequences, based on the tests above:
- Switching emoji is a URL change. Going from
/rocketto/fireis Scenario H: the new icon shows on the next page view. - An extra
?v=2is accepted. It returned the same SVG byte for byte, so you can use it as a version string if you ever need visitors to fetch an icon URL again.
The customised URL (?bg=…&shape=circle) came with a one-hour browser cache in my check, so a change of colour or shape also gets a new URL and shows up right away. The generator builds these URLs for you.
What this doesn't test
- Other browsers. Only Google Chrome 156 on Linux. Firefox and Safari have their own favicon handling. I didn't test them, so don't assume they behave the same.
- Long real-world waits. The longest wait was 15 seconds with a 10-second cache. I didn't wait out a real 24-hour
max-age, and I don't know when Chrome's own favicon store drops an entry on its own. - Bookmarks, history, home-screen and search-result icons. These are stored and refreshed separately; installed web apps take their icons from the manifest.
- Mobile browsers, extensions, and corporate proxies that cache on their own.
The test script and all outputs are short enough to rerun on your own machine: a Python server, Playwright with your installed Chrome, and a screenshot of the tab strip.
For more on emoji icons in the tab, see the EmojiFavicons guide.
Need help with a project? The team behind FindUtils takes on freelance work on Upwork, including pixel-perfect HTML from your Figma or PSD designs, with favicons and icons set up so updates reach your visitors.
Sumber artikel open-source oleh FindUtils di DEV Community — Baca artikel asli. Topik:
#webdev#html#frontend#beginners

Komentar