Skip to content
Snippets Groups Projects
Commit 4f3c4962 authored by Ben Coburn's avatar Ben Coburn
Browse files

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
parent b1112787
No related branches found
No related tags found
No related merge requests found
...@@ -204,14 +204,15 @@ function calc_cache($cache){ ...@@ -204,14 +204,15 @@ function calc_cache($cache){
function get_from_URL($url,$ext,$cache){ function get_from_URL($url,$ext,$cache){
global $conf; global $conf;
// if 'nocache' just redirect
if ($cache==0) { return false; }
$local = getCacheName(strtolower($url),".media.$ext"); $local = getCacheName(strtolower($url),".media.$ext");
$mtime = @filemtime($local); // 0 if not exists $mtime = @filemtime($local); // 0 if not exists
//decide if download needed: //decide if download needed:
if( $cache == 0 || // never cache if( ($mtime == 0) || // cache does not exist
($mtime != 0 && $cache != -1) || // exists but no endless cache ($cache != -1 && $mtime < time()-$cache) // 'recache' and cache has expired
($mtime == 0) || // not exists
($cache != -1 && $mtime < time()-$cache) // expired
){ ){
if(io_download($url,$local)){ if(io_download($url,$local)){
return $local; return $local;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment