nextcloud-oidc-login icon indicating copy to clipboard operation
nextcloud-oidc-login copied to clipboard

Cache the avatar requests

Open azmeuk opened this issue 2 years ago • 3 comments

Avatars are downloaded with curl:

https://github.com/pulsejet/nextcloud-oidc-login/blob/6ef0578b9dfeb91e4a737eab6a8d31eedee6977a/lib/Service/LoginService.php#L377-L395

However there is no notion of Etag or Last-Modified header, making the avatar being downloaded at each authentication.

We should maintain a small cache with ETag and Last-Modified response headers, and pass them back in If-None-Match and If-Modified-Since headers for following requests, and ignore avatar update when we meet a 304 code.

azmeuk avatar Mar 18 '23 07:03 azmeuk

IAvatarManager::getAvatar::getFile::getMTime?

pulsejet avatar Mar 18 '23 17:03 pulsejet

IAvatarManager::getAvatar::getFile::getMTime?

That sounds promising for the Last-Modified header. However to handle Etag we might need to some caching. Last-Modified definitively sounds an easy first step.

azmeuk avatar Mar 18 '23 17:03 azmeuk

For the record, Last-Modified header support came with #220 in version 2.5.0

azmeuk avatar Apr 21 '23 09:04 azmeuk