Issue #22 - Added headers to cache files and changed filenames to a sha1 hash of its contents.

This commit is contained in:
Daniel Thee Roperto
2016-11-09 11:31:54 +11:00
parent 32e44ea86c
commit f086fc1af7
3 changed files with 20 additions and 22 deletions

View File

@@ -44,12 +44,15 @@ if (isset($_GET['file'])) {
}
// Detect type, we only support css or PNG images.
$type = substr($file, -3);
if ($type == 'css') {
header('Content-type: text/css');
} else {
header('Content-type: image/png');
}
header('Content-Type: '.(substr($file, -3) == 'css' ? 'text/css' : 'image/png'));
// Use cache.
$lifetime = 60 * 60 * 24; // 1 day.
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
header('Pragma: ');
header('Cache-Control: public, max-age='.$lifetime);
header('Accept-Ranges: none');
readfile($file);
return;
}