Reputation: 335
I have an application developed in zend framework. I need to make sure browser is not using cache each time it loads my site. Is there a way to make zend clear cache for every visit? i'm looking for possibly ini setting .
Upvotes: 3
Views: 975
Reputation: 1682
If you use sessions (Zend_Session
), PHP sends those headers automatically.
If you don't use sessions, inside a Zend controller, you can use this:
<?php
class SomeController extends Zend_Controller_Action {
function indexAction(){
$this->getResponse()->setHeader('Cache-Control','no-store, no-cache, must-revalidate, post-check=0, pre-check=0',1);
$this->getResponse()->setHeader('Expires','Thu, 19 Nov 1981 08:52:00 GMT',1);
$this->getResponse()->setHeader('Pragma','no-cache',1);
}
}
Upvotes: 2
Reputation: 361
I don't know if it is a good idea, but you could start from reading this:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
at the 14.9 paragraph. There is the complete explanation of the cache control.
For example, if you want to ensure that the user will see always the latest version you could set a short expiration time to the cache entries...
Be aware: if you don't let the browser to cache contents, every access it will be slow as the first loading... (especially if there are many images and "heavy" objects)
Good programming!
Upvotes: 0