I'm having trouble with Laravel 4. Somehow the header
Cache-Control: no-cache
Is always being sent in the response on all pages within my site. I can't find where or how to change it.
Since this is affecting all my controllers where I'm presenting a view with View::Make
I would really like a way to change this globally.
If you want to use Cache, you can change its behavior in your "Response" object (returned by a controller method in this example) :
public function myControllerMethod() {
$response = Response::make('something');
$response->setLastModified(new DateTime("now"));
$response->setExpires(new DateTime("tomorrow"));
return $response;
}
It works in my environnement, I hope it will help.
EDIT:
If you want to set it globally, you can try this (in app/start/
directory):
App::after(function($request, $response) {
$response->setLastModified(new DateTime("now"));
$response->setExpires(new DateTime("tomorrow"));
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With