MDL-28709: Performance: Send cache/contenttype headers with 304 responses

This commit is contained in:
Tony Levi
2011-08-11 14:34:54 +09:30
committed by Petr Skoda
parent 24654d977b
commit 716f93efdb
4 changed files with 57 additions and 22 deletions
+6 -1
View File
@@ -53,6 +53,10 @@ if ($rev > -1 and file_exists($candidate)) {
// we do not actually need to verify the etag value because our files
// never change in cache because we increment the rev parameter
header('HTTP/1.1 304 Not Modified');
$lifetime = 60*60*24*30; // 30 days
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
header('Cache-Control: max-age='.$lifetime);
header('Content-Type: application/javascript; charset=utf-8');
die;
}
send_cached_js($candidate, $rev);
@@ -88,12 +92,13 @@ if ($rev > -1) {
// parameters to get the best performance.
function send_cached_js($jspath) {
$lifetime = 60*60*24*20;
$lifetime = 60*60*24*30; // 30 days
header('Content-Disposition: inline; filename="javascript.php"');
header('Last-Modified: '. gmdate('D, d M Y H:i:s', filemtime($jspath)) .' GMT');
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
header('Pragma: ');
header('Cache-Control: max-age='.$lifetime);
header('Accept-Ranges: none');
header('Content-Type: application/javascript; charset=utf-8');
if (!min_enable_zlib_compression()) {