dokufreaks/plugin-filelist

New parameter nocache

Closed this issue · 2 comments

In some times the media data is periodicaly overwritten. Because of the cache behaviour of browsers this can effect in displaying old versions of the media documens. To avoid this I've added a possibility to switch off the cache by command in the filterlist syntax:
{{filterlist>[path/files]&nocache=1}}
Default is 'nocache=0' to enable caching.

To get this parameter the file 'syntax.php' has to be modified:

    ...
      $params = array(
          'sort' => 'name',
          'order' => 'asc',
          'index' => 0,
          'limit' => 0,
          'offset' => 0,
          'style' => 'list',
          'tableheader' => 0,
          'tableshowsize' => 0,
          'tableshowdate' => 0,
          'direct' => 0,
          'recursive' => 0,
          'titlefile' => '_title.txt',
          'cache' => 0,
    //added parameter 'nocache'
           'nocache' => 0,
      );

    ...

    function _render_link($filename, $filepath, $basedir, $webdir, $params, &$renderer) {
      global $conf;

    //prepare for formating
    $link['target'] = $conf['target']['extern'];
    $link['style']  = '';
    $link['pre']    = '';
    $link['suf']    = '';
    $link['more']   = '';
    $link['class']  = 'media';
    //added parameter 'nocache'
    if (!$params['direct']) {
        if (!$params['nocache']) {
            $link['url'] = ml(':'.$this->_convert_mediapath($filepath));
        } else {
            $link['url'] = ml(':'.$this->_convert_mediapath($filepath)) . '&nocache';
        }
    } else {
        if (!$params['nocache']) {
            $link['url'] = $webdir.substr($filepath, strlen($basedir));
        } else {
            $link['url'] = $webdir.substr($filepath, strlen($basedir)) . '&nocache';
        }
    }
    $link['name']   = $filename;

    ...

Regards
Juergen

  1. The parameter should be attached with a ? not & so it should be ?nocache
  2. The nocache parameter did not work with my firefox. The files where still cached.

So I implemented a different approach:

If you set the parameter randlinks=1 then random links will be created with a timestamp as a URL parameter. This at least gives the user the latest version of the file after refreshing the page because the link always changes. I had a look at some forums and this also seemed to be the preferred solution to this problem.

Disabling caching for links has been implemented with a new parameter randlinks, see #13. So this can be closed.