pulsejet / nextcloud-oidc-login

Nextcloud login via a single OpenID Connect 1.0 provider
https://apps.nextcloud.com/apps/oidc_login
GNU Affero General Public License v3.0
220 stars 59 forks source link

Cache the avatar requests #219

Open azmeuk opened 1 year ago

azmeuk commented 1 year ago

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.

pulsejet commented 1 year ago

IAvatarManager::getAvatar::getFile::getMTime?

azmeuk commented 1 year ago

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 commented 1 year ago

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