diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-12-01 13:48:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-01 13:48:55 +0100 |
commit | de807fd88214c45b47e1b45c0c4933f2c6bcf36f (patch) | |
tree | 1d3c200498da3ebe9c67a546aa102780955a84db | |
parent | 1eab2a63c63dcfd3b5b225cb553351b0f76a9419 (diff) | |
parent | 5c602f32177e553fdb86c2f1ef5a6a85beb98913 (diff) | |
download | nextcloud-server-de807fd88214c45b47e1b45c0c4933f2c6bcf36f.tar.gz nextcloud-server-de807fd88214c45b47e1b45c0c4933f2c6bcf36f.zip |
Merge pull request #2416 from nextcloud/cache_all_avatar_responses
Cache all avatar responses
-rw-r--r-- | core/Controller/AvatarController.php | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/core/Controller/AvatarController.php b/core/Controller/AvatarController.php index 5e3d563cf2c..5a3d6309149 100644 --- a/core/Controller/AvatarController.php +++ b/core/Controller/AvatarController.php @@ -133,16 +133,6 @@ class AvatarController extends Controller { $resp = new FileDisplayResponse($avatar, Http::STATUS_OK, ['Content-Type' => $avatar->getMimeType()]); - - // Let cache this! - $resp->addHeader('Pragma', 'public'); - // Cache for 15 minutes - $resp->cacheFor(900); - - $expires = new \DateTime(); - $expires->setTimestamp($this->timeFactory->getTime()); - $expires->add(new \DateInterval('PT15M')); - $resp->addHeader('Expires', $expires->format(\DateTime::RFC2822)); } catch (NotFoundException $e) { $user = $this->userManager->get($userId); $resp = new JSONResponse([ @@ -150,20 +140,24 @@ class AvatarController extends Controller { 'displayname' => $user->getDisplayName(), ], ]); - // Don't cache this - $resp->cacheFor(0); - $resp->setLastModified(new \DateTime('now', new \DateTimeZone('GMT'))); } catch (\Exception $e) { $resp = new JSONResponse([ 'data' => [ 'displayname' => '', ], ]); - // Don't cache this - $resp->cacheFor(0); - $resp->setLastModified(new \DateTime('now', new \DateTimeZone('GMT'))); } + // Let cache this! + $resp->addHeader('Pragma', 'public'); + // Cache for 30 minutes + $resp->cacheFor(1800); + + $expires = new \DateTime(); + $expires->setTimestamp($this->timeFactory->getTime()); + $expires->add(new \DateInterval('PT30M')); + $resp->addHeader('Expires', $expires->format(\DateTime::RFC1123)); + return $resp; } |