-
Bug
-
Resolution: Fixed
-
Minor
-
2.7.2
-
MOODLE_27_STABLE
-
MOODLE_27_STABLE, MOODLE_28_STABLE
-
m29_
MDL-48023_Theme_Setting_Files_Cacheable_By_Both_Browsers_And_Proxies -
Hi,
there are some images that my reverse-proxy doesn't cache because of bad Cache-Control header from pluginfile.php.
The header looks like:
Cache-Control: private, max-age=31536000, no-transform
On such files like user icons:
...pluginfile.php/5/user/icon/essential/f2?rev=155
Background image:
...pluginfile.php/1/theme_essential/pagebackground/1414917278/lusisbackground.jpg
Logo:
...pluginfile.php/1/theme_essential/logo/1414917278/lusis.jpg
and so on.
These files come from theme (plugin). But there is no way for plugin to control Cache-control header.
In file lib/filelib.php there is:
if ($lifetime > 0) {
|
$private = '';
|
if (isloggedin() and !isguestuser()) {
|
$private = ' private,';
|
}
|
header('Cache-Control:'.$private.' max-age='.$lifetime.', no-transform');
|
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
|
header('Pragma: ');
|
}
|
So every logged in user hits php for numerous static files and creates a big load on server. But with correct headers these files could be served from reverse-proxy without accessing web server at all.