From a custom plugin controller, I am returning data as json using $this->returnJson($data)
. I need to be able to set the Cache-Control headers for my forward cache proxy to handle caching correctly.
I tried using HeaderHelper::setExpires(300)
, but JsonHelper::sendJsonHeaders()
, which is called by $this->returnJson()
from the controller, overrides setExpires
by calling HeaderHelper::setNoCache()
.
Does anyone have any ideas for working around this or configuring returnJson
? I can do the following in my controller (or create a helper of my own):
HeaderHelper::setExpires(300);
HeaderHelper::setContentTypeByExtension('json');
ob_start();
echo JsonHelper::encode($return);
craft()->end();
but I'd rather use the super convenient returnJson
function.