I’ve been blissfully calling CakeResponse::disableCache(); from the beforeFilter() of AppController.php to disable browser caching and it has, as far as I can tell, been working well.
However, since upgrading to PHP5.4, I’m getting the following strict warning:
Strict (2048): Non-static method CakeResponse::disableCache()
should not be called statically, assuming $this from incompatible
context [APP/Controller/AppController.php, line 53]
The function still seems to be working but the error tells me that I’ve misunderstood something pretty fundamental and that there’s probably a different (and better) way of doing it.
So, if I need browser caching to be disabled on an app-wide basis (ie: no-store, no-cache, must-revalidate etc etc) then what’s the best way to do this in Cake 2.3?
why not accessing the CakeResponse object it how it is intended to be used in an OOP context? as part the controller:
So in your case:
There are also plenty of examples in the docs – like http://book.cakephp.org/2.0/en/controllers/request-response.html#interacting-with-browser-caching
have you read the book prior to asking the question?