Repository navigation
fix(favicon): keep the browser's cached icon when it revalidates - #389
Merged
Merged
Conversation
Site favicons disappeared from the dashboard about a day after they were first loaded. When the browser rechecked its cached icon, DuckDuckGo answered "not modified", and the proxy turned that into an empty response the browser then cached for a day in place of the icon. The proxy now passes 304 Not Modified through unchanged; other non-2xx answers still become an empty 204 so the dashboard shows its fallback. Browsers that already cached the empty response keep it until it expires (up to a day) or their cache is cleared.
Collaborator
|
Thanks a lot for that, looks good 🙂 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Site favicons in the dashboard turn into the globe fallback about a day after they first load, and a hard reload doesn't bring them back.
When the browser rechecks a cached icon, it sends
If-None-Match/If-Modified-Since. The proxy forwards those to DuckDuckGo, which answers 304 Not Modified.ModifyResponsetreated every non-2xx answer as "no icon" and turned the 304 into an empty 204 withCache-Control: public, max-age=86400. The browser then cached that empty response in place of the icon for another day. A hard reload doesn't help, because the dashboard adds its icons after the page has loaded, so they come from the cache.What changed
server/sites/favicon_handlers.go: a 304 now passes through unchanged. Other non-2xx answers still become an empty 204, so the dashboard shows its fallback when there's no icon.server/sites/handlers_test.go: a test that the browser's validator reaches the upstream request and the 304 comes back.To reproduce against a running instance:
Before this change the second command prints 204. With it, the command prints 304.
Browsers that already cached an empty response keep it until it expires (up to a day) or their cache is cleared.
Testing
go test -race ./server/sites -run Faviconpasses.hkQA profile.Contributor Checklist
No docs, OpenAPI, MCP, Agent Skills or AI changes. The only visible difference is that icons no longer disappear.
/api/favicon/{domain}can now also answer 304 to a conditional request.