nextcloud / talk-ios

📱😀 Video & audio calls through Nextcloud on iOS
GNU General Public License v3.0
146 stars 86 forks source link

Make sure we correctly cache avatars for up to 24h #1689

Closed SystemKeeper closed 2 weeks ago

SystemKeeper commented 3 weeks ago

Until now we used the SDWebImageRefreshCached option in SDWebImage to make sure we are using NSURLCache for caching and taking cache-control headers into account. NSURLCache seems to have trouble correctly caching URLs that have a query parameter added to them, which results in a requests made whenever an avatar is requested -> basically ignoring any caches.

We can't provide an avatarVersion for all avatars (user avatars, federated conversation avatars, etc.). Therefore we now disable the use of NSURLCache (and therefore rely on the aggressive caching SDWebImage is doing by default) but additionally append a hash from the current date to the URL. This way we can make sure that for each avatar only one request is done per day (as it is currently intended by the cache control header).