-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avatar caching doesn't work on Firefox #16964
Comments
What you saw in Firefox network log:
It seems there is no problem. If you believe you found a bug, just provide the expected behavior you thought it should be. |
Have you opened the option of firefox to |
And I do not think From the screenshots that the author provided, I do not think there is a serious problem. |
I meant 308, basically any "permanent" redirect should be cachable. Edited my comment above. I think browser should honor caching headers fine on such redirects, so they should eventually invalidate.
|
What's the difference between 301/308 and 302/307 if they both have cache control? |
There's probably no difference, browsers should cache all status codes as long as cache-control headers are in place. We do not set any so the current 302 with no cache-control headers is uncachable. It might have been if it were a 301/308. I think we just need to set cache headers on redirect responses like we already do on self-hosted avatars. |
From the above information and my test (on try.gitea.io and my private server), I do not think this is a gitea problem. Without the cache control header in 302 response, the response is still very quick. It can not cause the problem "20 seconds lag" described by the deleted comment. Even if we add the cache control, this author's problem can't be resolved. And the author just deleted the comment containing screenshots of his private server, you can refer that in email inbox (maybe some wrong configuration on the private server?) |
ps: if we add a cache control header in avatar's 302 response to reduce browser requests and reduce gitea server/database load, it would be helpful in other ways. LOL. |
Yes, I think it's good practice to always set cache-control. We can use time-based cache for avatar requests, e.g. gitea/modules/httpcache/httpcache.go Line 34 in 0767fe0
|
This does seem to do the trick to make the Avatar redirects cachable in Chrome. In Firefox, it does not seem to work, thought and I found no way to suppress the requests to the original URLs, I even tried setting an Etag to no avail. Related discussion in go-gitea#16964.
Caching of Avatar requests certainly works in Firefox. What does not work is the caching of the redirection response in case the Avatar is hosted externally. I did add cache headers to those redirects in #16973 but Firefox just seems to ignore them. I think this is the best we can do, unless someone has another idea. |
* Add Cache-Control to avatar redirects This does seem to do the trick to make the Avatar redirects cachable in Chrome. In Firefox, it does not seem to work, thought and I found no way to suppress the requests to the original URLs, I even tried setting an Etag to no avail. Related discussion in #16964. Co-authored-by: zeripath <art27@cantab.net>
#16973 got merged 🚀 |
Can't figure out why Firefox would not cache those redirects, maybe it has something to do with their privacy protection, I'm not sure. Couldn't find anything on Bugzilla either. It might be possible to directly render gravatar links without going through a redirect, but I think that method may not be possible for other federated avatar sources. |
If the cache of avatars responded by Gitea doesn't work (described in the original issue by author, on the private server), maybe it is caused by gitea/modules/httpcache/httpcache.go Line 21 in ab77a24
|
No, I am running |
(I mean the original problem described in this issue by the author. And the fix and the original problem seems off-topic now .... ) |
Yeah I think we can close this. OP has deleted any helpful information and is probably not going to respond any more. |
[x]
):Description
Avatar images aren't cached with Firefox, a new copy is always fetched on load.
On Chromium, it shows that avatar images are cached (in memory).
Screenshots
On Firefox, after a refresh:
The text was updated successfully, but these errors were encountered: