Question

I have a Piwik install sitting behind a varnish-caching server. My problem is varnish is by default caching responses to my API calls. Unfortunately, I don't have direct access to the varnish server, so I need to send the

"Cache-Control: no-cache"

header with my API responses. Is there a setting or a way to modify my piwik install to accomplish this? Thanks!

Was it helpful?

Solution

Add to .htaccess in your piwik install, core/API/ folder:

<Files Request.php>
  Header set Cache-Control "no-cache"
</Files>

If you need to add the header to other URLs, follow the same pattern.

Note that Piwik already adds Cache-Control: max-age=0 to these responses, so if that's not working for you on the Request.php path you probably want to add this to .htaccess in the folder with piwik.js (root of piwik install) as well:

<Files piwik.php>
  Header set Cache-Control "no-cache"
</Files>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top