mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-57965 performance: compress svg files with gzip
This commit is contained in:
parent
216ea39be7
commit
a56cf2e374
@ -235,13 +235,20 @@ function send_cached_image($imagepath, $etag) {
|
||||
header('Cache-Control: public, max-age='.$lifetime.', no-transform, immutable');
|
||||
header('Accept-Ranges: none');
|
||||
header('Content-Type: '.$mimetype);
|
||||
header('Content-Length: '.filesize($imagepath));
|
||||
|
||||
if (xsendfile($imagepath)) {
|
||||
die;
|
||||
}
|
||||
|
||||
// no need to gzip already compressed images ;-)
|
||||
if ($mimetype === 'image/svg+xml') {
|
||||
// SVG format is a text file. So we can compress SVG files.
|
||||
if (!min_enable_zlib_compression()) {
|
||||
header('Content-Length: '.filesize($imagepath));
|
||||
}
|
||||
} else {
|
||||
// No need to compress other image formats.
|
||||
header('Content-Length: '.filesize($imagepath));
|
||||
}
|
||||
|
||||
readfile($imagepath);
|
||||
die;
|
||||
|
Loading…
x
Reference in New Issue
Block a user