I have a page where I submit a form that I want to cache but only for get requests. I cannot figure out if there is a way to do this but the Yii2 guide seems to hint at it http://www.yiiframework.com/doc-2.0/yii-filters-pagecache.html#$enabled-detail, it says you can enable it only for Get requests. Anyone know how to filter this so it won't cache the page when the form is submitted. Right now when it submits the page goes into a redirect loop.
'pageCache' => [
'class' => 'yii\filters\PageCache',
'only' => ['nba'],
'dependency' => [
'class' => 'yii\caching\DbDependency',
'sql' => 'SELECT timestamp FROM e_NBApicks WHERE user_id = '.Yii::$app->user->Id,
],
],
Since enabled is a boolean just pass the
isGet
variable from\yii\web\Request
:The Request class represents an HTTP request. Read more on it from the API page