StaticController: improve cache headers

Apache does automagic stuff if we don't care (e.g. pragma). Playing
around with ETags, not happy yet.
This commit is contained in:
Thomas Gelf 2014-06-20 14:53:38 +02:00
parent 916c9c027e
commit 9411dec5d0
1 changed files with 5 additions and 2 deletions

View File

@ -85,11 +85,14 @@ class StaticController extends ActionController
$extension = 'fixme';
}
$s = stat($filePath);
header('Content-Type: image/' . $extension);
header('Cache-Control: max-age=3600');
header(sprintf('ETag: "%x-%x-%x"', $s['ino'], $s['size'], (float) str_pad($s['mtime'], 16, '0')));
header('Cache-Control: public, max-age=3600');
header('Pragma: cache');
header('Last-Modified: ' . gmdate(
'D, d M Y H:i:s',
filemtime($filePath)
$s['mtime']
) . ' GMT');
readfile($filePath);