diff options
author | Julius Haertl <jus@bitgrid.net> | 2016-10-14 14:57:58 +0200 |
---|---|---|
committer | Julius Haertl <jus@bitgrid.net> | 2016-11-18 10:23:24 +0100 |
commit | 2e8dd218157123cdb7f1741980e12dc22b95f320 (patch) | |
tree | 08cc47865cc2b20bc61f07dc2a35e084d0423eb3 /apps/theming/tests/Controller/IconControllerTest.php | |
parent | 492d0b9f9bd72591183ff8bf4e8d5f9b4aecba35 (diff) | |
download | nextcloud-server-2e8dd218157123cdb7f1741980e12dc22b95f320.tar.gz nextcloud-server-2e8dd218157123cdb7f1741980e12dc22b95f320.zip |
Improve caching
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Diffstat (limited to 'apps/theming/tests/Controller/IconControllerTest.php')
-rw-r--r-- | apps/theming/tests/Controller/IconControllerTest.php | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/apps/theming/tests/Controller/IconControllerTest.php b/apps/theming/tests/Controller/IconControllerTest.php index 82a937c3b91..98fa4f1a243 100644 --- a/apps/theming/tests/Controller/IconControllerTest.php +++ b/apps/theming/tests/Controller/IconControllerTest.php @@ -103,7 +103,10 @@ class IconControllerTest extends TestCase { ->willReturn($file); $expected = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => 'image/svg+xml']); $expected->cacheFor(86400); - $expected->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime())); + $expires = new \DateTime(); + $expires->setTimestamp($this->timeFactory->getTime()); + $expires->add(new \DateInterval('PT24H')); + $expected->addHeader('Expires', $expires->format(\DateTime::RFC2822)); $expected->addHeader('Pragma', 'cache'); @$this->assertEquals($expected, $this->iconController->getThemedIcon('core', 'filetypes/folder.svg')); @@ -133,7 +136,10 @@ class IconControllerTest extends TestCase { $expected = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => 'image/x-icon']); $expected->cacheFor(86400); - $expected->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime())); + $expires = new \DateTime(); + $expires->setTimestamp($this->timeFactory->getTime()); + $expires->add(new \DateInterval('PT24H')); + $expected->addHeader('Expires', $expires->format(\DateTime::RFC2822)); $expected->addHeader('Pragma', 'cache'); $this->assertEquals($expected, $this->iconController->getFavicon()); } @@ -143,9 +149,8 @@ class IconControllerTest extends TestCase { ->method('shouldReplaceIcons') ->willReturn(false); $expected = new DataDisplayResponse(null, Http::STATUS_NOT_FOUND); - $expected->cacheFor(86400); - $expected->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime())); - $expected->addHeader('Pragma', 'cache'); + $expected->cacheFor(0); + $expected->setLastModified(new \DateTime('now', new \DateTimeZone('GMT'))); $this->assertEquals($expected, $this->iconController->getFavicon()); } @@ -172,7 +177,10 @@ class IconControllerTest extends TestCase { $expected = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => 'image/png']); $expected->cacheFor(86400); - $expected->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime())); + $expires = new \DateTime(); + $expires->setTimestamp($this->timeFactory->getTime()); + $expires->add(new \DateInterval('PT24H')); + $expected->addHeader('Expires', $expires->format(\DateTime::RFC2822)); $expected->addHeader('Pragma', 'cache'); $this->assertEquals($expected, $this->iconController->getTouchIcon()); } @@ -182,9 +190,8 @@ class IconControllerTest extends TestCase { ->method('shouldReplaceIcons') ->willReturn(false); $expected = new DataDisplayResponse(null, Http::STATUS_NOT_FOUND); - $expected->cacheFor(86400); - $expected->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime())); - $expected->addHeader('Pragma', 'cache'); + $expected->cacheFor(0); + $expected->setLastModified(new \DateTime('now', new \DateTimeZone('GMT'))); $this->assertEquals($expected, $this->iconController->getTouchIcon()); } |