MDL-40545 convert js and theme resources to localcachedir

This commit is contained in:
Petr Škoda 2013-07-13 00:05:58 +02:00
parent 85b3806114
commit cb8108dd22
6 changed files with 7 additions and 11 deletions

View File

@ -79,7 +79,7 @@ $etag = sha1($rev.implode(',', $jsfiles));
// Use the caching only for meaningful revision numbers which prevents future cache poisoning.
if ($rev > 0 and $rev < (time() + 60*60)) {
$candidate = $CFG->cachedir.'/js/'.$etag;
$candidate = $CFG->localcachedir.'/js/'.$etag;
if (file_exists($candidate)) {
if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {

View File

@ -44,7 +44,6 @@ require_once($CFG->libdir.'/outputrequirementslib.php');
*/
function theme_reset_all_caches() {
global $CFG, $PAGE;
require_once("$CFG->libdir/filelib.php");
$next = time();
if (isset($CFG->themerev) and $next <= $CFG->themerev and $CFG->themerev - $next < 60*60) {
@ -55,7 +54,6 @@ function theme_reset_all_caches() {
}
set_config('themerev', $next); // time is unique even when you reset/switch database
fulldelete("$CFG->cachedir/theme");
if ($PAGE) {
$PAGE->reload_theme();

View File

@ -1744,7 +1744,6 @@ class YUI_config {
*/
function js_reset_all_caches() {
global $CFG;
require_once("$CFG->libdir/filelib.php");
$next = time();
if (isset($CFG->jsrev) and $next <= $CFG->jsrev and $CFG->jsrev - $next < 60*60) {
@ -1755,5 +1754,4 @@ function js_reset_all_caches() {
}
set_config('jsrev', $next);
fulldelete("$CFG->cachedir/js");
}

View File

@ -74,7 +74,7 @@ if (file_exists("$CFG->dirroot/theme/$themename/config.php")) {
image_not_found();
}
$candidatelocation = "$CFG->cachedir/theme/$rev/$themename/pix/$component";
$candidatelocation = "$CFG->localcachedir/theme/$rev/$themename/pix/$component";
$etag = sha1("$rev/$themename/$component/$image");
if ($rev > 0) {
@ -142,7 +142,7 @@ if ($themerev <= 0 or $rev != $themerev) {
send_uncached_image($imagefile);
}
make_cache_directory('theme', false);
make_localcache_directory('theme', false);
// We're not using SVG and there is no cached version of this file (in any format).
// As we're going to be caching a format other than svg, and because svg use is conditional we need to ensure that at the same

View File

@ -63,7 +63,7 @@ if (file_exists("$CFG->dirroot/theme/$themename/config.php")) {
die('Theme was not found, sorry.');
}
$candidate = "$CFG->cachedir/theme/$rev/$themename/javascript_$type.js";
$candidate = "$CFG->localcachedir/theme/$rev/$themename/javascript_$type.js";
$etag = sha1("$rev/$themename/$type");
if ($rev > 0 and file_exists($candidate)) {
@ -93,7 +93,7 @@ if ($themerev <= 0 or $rev != $themerev) {
js_send_uncached($theme->javascript_content($type));
}
make_cache_directory('theme', false);
make_localcache_directory('theme', false);
js_write_cache_file_content($candidate, js_minify($theme->javascript_files($type)));
// Verify nothing failed in cache file creation.

View File

@ -87,7 +87,7 @@ if (file_exists("$CFG->dirroot/theme/$themename/config.php")) {
die('Theme was not found, sorry.');
}
$candidatedir = "$CFG->cachedir/theme/$rev/$themename/css";
$candidatedir = "$CFG->localcachedir/theme/$rev/$themename/css";
$etag = "$rev/$themename/$type";
$candidatename = $type;
if (!$usesvg) {
@ -148,7 +148,7 @@ if ($themerev <= 0 or $themerev != $rev) {
$etag = sha1($etag);
}
make_cache_directory('theme', false);
make_localcache_directory('theme', false);
if ($type === 'editor') {
$cssfiles = $theme->editor_css_files();