yii2: http caching always return status 200
What steps will reproduce the problem?
use http cache etag[
'class' => 'yii\filters\HttpCache',
'only' => ['show', 'pdf', 'show-video', 'show-doc'],
'etagSeed' => function ($action, $params) {
$file = UploadedFile::findOne(['id' => \Yii::$app->request->get('id')]);
if($file){
return serialize([$file->id, $file->created_at]);
}
},
'sessionCacheLimiter' => 'public',
],
What's expected?
Next request should cache return http status 304(not modified)What do you get instead?

return http status 200 each request
Additional info
| Q | A |
|---|---|
| Yii version | 2.0.38 |
| PHP version | 7.3 |
| Web Server | Apche 2.4.6 http 1.1 |
| Operating system | Centos 7 |
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19 (10 by maintainers)
I cannot reproduce your case. I told you what might be a reason based on the code flow. I have found this issue - maybe this is the reason.
echoautomatically makes PHP to send headers. After that, no more headers could be sent including ETag.