I’m writing an app whose main action, SiteController::actionIndex, interacts with a database.
However, all other pages of the app are text pages displaying static content, for example, an About page, a Help page, etc. These are very unlikely to change, so I’d like to cache them. These pages are accessible via
index.php/site/page?view=about
index.php/site/page?view=help
etc.
I’d like to cache the text pages, but not cache the content generated by SiteController::actionIndex.
It seems to me that the URL’s will vary by the “view” parameter. So, I tried to accomplish this task with this code, which fails:
public function filters()
{
return array(
array(
'COutputCache',
'duration'=>3600,
'varyByParam'=>array('view'),
),
);
}
I also tried variations on specifying the unique parameter set, such as those shown below, but none worked, e.g.:
'varyByRoute'=>true,
'varyByParam'=>array('page'),
'varyByParam'=>array('page','view'),
This is surely something that many folks have tried to do, so if you can help me out, I would greatly appreciate it!
Emily