How to send "Cache-Control: no-cache" header in Piwik API responses


#1

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!


(vipsoft) #2

We’re already doing this. http://dev.piwik.org/trac/browser/trunk/index.php#L37


#3

That’s weird then. I’m using PHPFog for my hosting and they provide a varnish caching server for every application that’s hosted with them. Normally it works pretty well, but I’m seeing my Piwik API requests getting cached for some reason.

The documentation my hosting provider has states:
http://docs.phpfog.com/index.php/features/article/caching

[b]"To prevent caching set the “Cache-Control” header to “no-cache”. This is generally required in applications which don’t produce/consume cookies, but have contents that is actually dynamic. Here is the PHP example to set the Cache-Control header.

header(“Cache-Control: no-cache”);"[/b]

But if Piwik is already sending this header, why is Varnish caching my requests? I’ve attached a screenshot of what I’m seeing.


(Matthieu Aubry) #4

I don’t see the http header in the response from demo.piwik.org neither.

Maybe we don’t currently add this in APi responses?