I believe CakePHP clears cache in the following manner:
1. If there is an element ie. `articles_most_viewed.ctp` and it is
called from within `articles index.ctp` file, then Cake will clear
that respective element during an add, edit, delete action.
2. However, if there is an element ie. `frontpage_lastest_articles.ctp`
and it is only called in `pages/display.ctp` file (frontpage), then
CakePHP will not clear that element since it is not being called
from within the `affected/changed model/view`, in this case articles
`model/controller/view`.
I havent figure out how to better approach this issue, if there is a better way. However, my quick fix is to call clearCache() in my `admin_add.ctp`, `admin_edit.ctp` and `admin_delete.ctp` files as such:
...
function admin_add(){
...
if (!empty($this->data)) {
if ($this->Article->save($this->data)) {
clearCache();
$this->Session->setFlash('Your post has been saved.');
$this->redirect(array('action' => 'index'));
}
}
}
There might be a better way to handle this. Use this if it fits to you.
I believe CakePHP clears cache in the following manner:
1. If there is an element ie. `articles_most_viewed.ctp` and it is called from within `articles index.ctp` file, then Cake will clear that respective element during an add, edit, delete action.
2. However, if there is an element ie. `frontpage_lastest_articles.ctp` and it is only called in `pages/display.ctp` file (frontpage), then CakePHP will not clear that element since it is not being called from within the affected/changed model/view, in this case `articles` model/controller/view.
I havent figure out how to better approach this issue, if there is a better way. However, my quick fix is to call `clearCache()` in my `admin_add.ctp`, `admin_edit.ctp` and `admin_delete.ctp` files as such:
...
function admin_add(){
...
if (!empty($this->data)) {
if ($this->Article->save($this->data)) {
// I call the following function to clear my entire Cache directory
// after this action is successfully processed
// ===========================================
clearCache();
// ===========================================
$this->Session->setFlash('Your post has been saved.');
$this->redirect(array('action' => 'index'));
}
}
}
There might be a better way to handle this, but this is my solution for now. I would be glad to know if there is a better/automagic solution.