MDL-38743 add private cache headers

This commit is contained in:
Petr Škoda
2013-11-06 13:59:21 +08:00
committed by Dan Poltawski
parent 759ad16cc7
commit fc7c554de6
+13 -5
View File
@@ -2128,7 +2128,7 @@ function send_temp_file($path, $filename, $pathisstring=false) {
header('Content-Disposition: attachment; filename="'.$filename.'"');
if (strpos($CFG->wwwroot, 'https://') === 0) { //https sites - watch out for IE! KB812935 and KB316431
header('Cache-Control: max-age=10');
header('Cache-Control: private, max-age=10');
header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
header('Pragma: ');
} else { //normal http - prevent caching at all cost
@@ -2214,15 +2214,19 @@ function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathiss
}
if ($lifetime > 0) {
$private = '';
if (isloggedin() and !isguestuser()) {
$private = ' private,';
}
$nobyteserving = false;
header('Cache-Control: max-age='.$lifetime);
header('Cache-Control:'.$private.' max-age='.$lifetime);
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
header('Pragma: ');
} else { // Do not cache files in proxies and browsers
$nobyteserving = true;
if (strpos($CFG->wwwroot, 'https://') === 0) { //https sites - watch out for IE! KB812935 and KB316431
header('Cache-Control: max-age=10');
header('Cache-Control: private, max-age=10');
header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
header('Pragma: ');
} else { //normal http - prevent caching at all cost
@@ -2378,13 +2382,17 @@ function send_stored_file($stored_file, $lifetime=86400 , $filter=0, $forcedownl
}
if ($lifetime > 0) {
header('Cache-Control: max-age='.$lifetime);
$private = '';
if (isloggedin() and !isguestuser()) {
$private = ' private,';
}
header('Cache-Control:'.$private.' max-age='.$lifetime);
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
header('Pragma: ');
} else { // Do not cache files in proxies and browsers
if (strpos($CFG->wwwroot, 'https://') === 0) { //https sites - watch out for IE! KB812935 and KB316431
header('Cache-Control: max-age=10');
header('Cache-Control: private, max-age=10');
header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
header('Pragma: ');
} else { //normal http - prevent caching at all cost