ModuleController: Rename ETag to etag and change Response headers (imageAction)

This commit is contained in:
Jennifer Mourek 2017-10-25 14:36:41 +02:00
parent 48742e1333
commit 12a694787b
1 changed files with 7 additions and 11 deletions

View File

@ -148,14 +148,14 @@ class ModuleController extends DocController
$imageInfo = new SplFileInfo($imagePath);
$ETag = md5($imageInfo->getMTime() . $imagePath);
$etag = md5($imageInfo->getMTime() . $imagePath);
$lastModified = gmdate('D, d M Y H:i:s T', $imageInfo->getMTime());
$match = false;
if (isset($_SERER['HTTP_IF_NONE_MATCH'])) {
$ifNoneMatch = explode(', ', stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
foreach ($ifNoneMatch as $tag) {
if ($tag === $ETag) {
if ($tag === $etag) {
$match = true;
break;
}
@ -167,20 +167,16 @@ class ModuleController extends DocController
}
}
$finfo = new finfo();
$this->getResponse()
->setHeader('ETag', $ETag)
->setHeader('Cache-Control', 'no-transform,public,max-age=3600', true)
->setHeader('Last-Modified', $lastModified, true)
// Set additional headers for compatibility reasons (Cache-Control should have precedence) in case
// session.cache_limiter is set to no cache
->setHeader('Pragma', 'cache', true)
->setHeader('Expires', gmdate('D, d M Y H:i:s T', time() + 3600), true)
->setHeader('Content-Type', $finfo->file($imagePath, FILEINFO_MIME_TYPE));
->setHeader('ETag', $etag)
->setHeader('Cache-Control', 'no-transform,public,max-age=3600,must-revalidate', true);
if ($match) {
$this->getResponse()->setHttpResponseCode(304);
} else {
$finfo = new finfo();
$this->getResponse()
->setHeader('Content-Type', $finfo->file($imagePath, FILEINFO_MIME_TYPE));
readfile($imagePath);
}
}