MDL-26028 use X-Sendfile for theme images and javascript
This commit is contained in:
@@ -138,6 +138,9 @@ if ($rev > -1) {
|
||||
// parameters to get the best performance.
|
||||
|
||||
function send_cached_image($imagepath, $rev) {
|
||||
global $CFG;
|
||||
require("$CFG->dirroot/lib/xsendfilelib.php");
|
||||
|
||||
$lifetime = 60*60*24*30; // 30 days
|
||||
$pathinfo = pathinfo($imagepath);
|
||||
$imagename = $pathinfo['filename'].'.'.$pathinfo['extension'];
|
||||
@@ -154,6 +157,10 @@ function send_cached_image($imagepath, $rev) {
|
||||
header('Content-Type: '.$mimetype);
|
||||
header('Content-Length: '.filesize($imagepath));
|
||||
|
||||
if (xsendfile($imagepath)) {
|
||||
die;
|
||||
}
|
||||
|
||||
// no need to gzip already compressed images ;-)
|
||||
|
||||
readfile($imagepath);
|
||||
|
||||
@@ -99,6 +99,9 @@ if ($rev > -1) {
|
||||
// parameters to get the best performance.
|
||||
|
||||
function send_cached_js($jspath) {
|
||||
global $CFG;
|
||||
require("$CFG->dirroot/lib/xsendfilelib.php");
|
||||
|
||||
$lifetime = 60*60*24*30; // 30 days
|
||||
|
||||
header('Content-Disposition: inline; filename="javascript.php"');
|
||||
@@ -108,6 +111,11 @@ function send_cached_js($jspath) {
|
||||
header('Cache-Control: max-age='.$lifetime);
|
||||
header('Accept-Ranges: none');
|
||||
header('Content-Type: application/javascript; charset=utf-8');
|
||||
|
||||
if (xsendfile($jspath)) {
|
||||
die;
|
||||
}
|
||||
|
||||
if (!min_enable_zlib_compression()) {
|
||||
header('Content-Length: '.filesize($jspath));
|
||||
}
|
||||
|
||||
@@ -66,6 +66,9 @@ yui_image_cached($imagepath);
|
||||
|
||||
|
||||
function yui_image_cached($imagepath) {
|
||||
global $CFG;
|
||||
require("$CFG->dirroot/lib/xsendfilelib.php");
|
||||
|
||||
$lifetime = 60*60*24*300; // 300 days === forever
|
||||
$pathinfo = pathinfo($imagepath);
|
||||
$imagename = $pathinfo['filename'].'.'.$pathinfo['extension'];
|
||||
@@ -88,6 +91,10 @@ function yui_image_cached($imagepath) {
|
||||
header('Content-Type: '.$mimetype);
|
||||
header('Content-Length: '.filesize($imagepath));
|
||||
|
||||
if (xsendfile($imagepath)) {
|
||||
die;
|
||||
}
|
||||
|
||||
// no need to gzip already compressed images ;-)
|
||||
|
||||
readfile($imagepath);
|
||||
|
||||
Reference in New Issue
Block a user