From 4f3c4962cebeec6b73456cbacbf7f219ccb90c85 Mon Sep 17 00:00:00 2001 From: Ben Coburn <btcoburn@silicodon.net> Date: Fri, 21 Apr 2006 03:22:10 +0200 Subject: [PATCH] bugfix fetch remote media (recache and nocache) Fixes a major bug in fetching remote media with 'recache' and improves the efficiency of 'nocache'. Recache: - Used to reload the remote media on EVERY request. - Now it behaves as intended and only reloads the remote media into the Dokuwiki cache every $conf['cachetime'] time. Nocache: - No longer stores remote media in the Dokuwiki cache. - No longer loads, saves, and forwards remote media -- just redirects. - No longer resizes images on the server because the cached results can not be reused. Overall this is faster for Dokuwiki. The bandwidth usage for the 3rd party server is the same (less for Dokuwiki). Page loading should also be faster because data is not being forwarded through Dokuwiki (and the 3rd part server's cache control headers will be respected automatically). darcs-hash:20060421012210-05dcb-a6029baa0fad218ace28e0e3c2f442b1ca645a99.gz --- lib/exe/fetch.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php index 87c47d7cb..9157baeb8 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -204,14 +204,15 @@ function calc_cache($cache){ function get_from_URL($url,$ext,$cache){ global $conf; + // if 'nocache' just redirect + if ($cache==0) { return false; } + $local = getCacheName(strtolower($url),".media.$ext"); $mtime = @filemtime($local); // 0 if not exists //decide if download needed: - if( $cache == 0 || // never cache - ($mtime != 0 && $cache != -1) || // exists but no endless cache - ($mtime == 0) || // not exists - ($cache != -1 && $mtime < time()-$cache) // expired + if( ($mtime == 0) || // cache does not exist + ($cache != -1 && $mtime < time()-$cache) // 'recache' and cache has expired ){ if(io_download($url,$local)){ return $local; -- GitLab