matomo-org/matomo-nginx

$no_cache better setting and cache for ui

celogeek opened this issue · 1 comments

Hi, thanks for the over patch, but I have suggestion :

for piwik.php the no_cache should be always set to 0.
for ui, we can have another directory of cache, with all module except POST and Real TIME cache.
All setting should no be cache too.

I run the crontab (archive.sh) every 5 min, or anything,
when the archive run, we can delete the cache directory to force a refresh.
another way, is to set the time of cache equal to the frequency you run the archive.sh.

So 2 vars could be add :

time_of_cache
subdir_for_cache

for piwiki.php
no_cache=0
time_of_cache = 2h
subdir_for_cache = stats

for index.php
time_of_cache = 5m (or anything we set for the crontab)
subdir_for_cache = ui (may be autodelete by crontab, but if time_of_cache is set the same skip the delete)
no_cache = 1 by default
except : module for stats

or no_cache = 0 by default
except POST, configuration module

I will setup this, and purpose a patch

well we can use "set" for setting time.

Here my tweak to make it work with the ui :

## Relay all index.php requests to fastcgi.
location = /index.php {
    fastcgi_pass phpcgi;
    ## FastCGI cache.
    set $no_cache 0;
    if ($query_string ~ "module=[^\&]*(Live|Admin|Manager)") {
            set $no_cache 1;
    }
    include sites-available/fcgi_cache.conf;
    fastcgi_cache_valid 5m;
    ## To use Apache for serving PHP uncomment the line bellow and
    ## comment out the above.
    #proxy_pass http://phpapache;
}


## Relay all piwik.php requests to fastcgi.
location = /piwik.php {
    fastcgi_pass phpcgi;
    ## FastCGI cache.
    set $no_cache 0;
    include sites-available/fcgi_cache.conf;
    ## To use Apache for serving PHP uncomment the line bellow and
    ## comment out the above.
    #proxy_pass http://phpapache;
    ## Proxy cache.
    #include sites-available/proxy_cache.conf;
}

So "cache" for piwik, with 2h.
And "cache" for ui for 5m (time of my cron), except for Admin / Manager and Live module :)