What's the best way to achieve this?
My current process is:
-Controller performs query (mostly via models)
-Controller initiates view
-Controller passes set of models to the view
-Controller displays view
What I want to do, is cache view and just output it without re-doing the queries.
What's the best technique for this?
The simplest one would be something like:
(obviously need a flag to reset the cache when something changes)PHP Code:if (file_exists($cachefile)) {
//display cache
}
else {
//do above process and save output to file
}
But it somewhat doesn't feel right giving the responsibility of caching to the controller.
Should the caching be done in the view? If so, the query needs to be run in the view, which definately isnt right.
I guess my question is, is the controller the 'correct' place to deal with the caching.
*obviously in the real world, a cache object would deal with the file IO but i wanted to keep my example simple







Bookmarks