diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-08-29 14:55:23 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-08-30 09:00:16 +0200 |
commit | 14136295b7568c6e34504c101eba0ee10f5c74fd (patch) | |
tree | 8fa8c31163b4a4fc8621919f330f22e5631af385 /core/js/jquery.avatar.js | |
parent | c481210e2b24706f4cb0159bd82eb16ec58d9e92 (diff) | |
download | nextcloud-server-14136295b7568c6e34504c101eba0ee10f5c74fd.tar.gz nextcloud-server-14136295b7568c6e34504c101eba0ee10f5c74fd.zip |
Cache avatars properly
* Set proper caching headers for avatars (15 minutes)
* For our own avatar use some extra logic to invalidate when we update
Diffstat (limited to 'core/js/jquery.avatar.js')
-rw-r--r-- | core/js/jquery.avatar.js | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/core/js/jquery.avatar.js b/core/js/jquery.avatar.js index 6ae9cf78a13..754400acd7b 100644 --- a/core/js/jquery.avatar.js +++ b/core/js/jquery.avatar.js @@ -74,10 +74,25 @@ user = String(user).replace(/\//g,''); var $div = this; + var url; - var url = OC.generateUrl( - '/avatar/{user}/{size}', - {user: user, size: Math.ceil(size * window.devicePixelRatio)}); + // If this is our own avatar we have to use the version attribute + if (user === OC.getCurrentUser().uid) { + url = OC.generateUrl( + '/avatar/{user}/{size}?v={version}', + { + user: user, + size: Math.ceil(size * window.devicePixelRatio), + version: oc_userconfig.avatar.version + }); + } else { + url = OC.generateUrl( + '/avatar/{user}/{size}', + { + user: user, + size: Math.ceil(size * window.devicePixelRatio) + }); + } // If the displayname is not defined we use the old code path if (typeof(displayname) === 'undefined') { @@ -122,7 +137,7 @@ $div.show(); $div.text(''); $div.append(img); - } + }; img.width = size; img.height = size; |