protected function validateCache($lastModified, $etag)
    {
        $request = Yii::getApp()->getRequest();
        if ($request->hasHeader('if-none-match')) {
            // 'if-none-match' takes precedence over 'if-modified-since'
            // http://tools.ietf.org/html/rfc7232#section-3.3
            return $etag !== null && in_array($etag, Yii::getApp()->request->getETags(), true);
        } elseif ($request->hasHeader('if-modified-since')) {
            return $lastModified !== null && @strtotime($request->getHeaderLine('if-modified-since')) >= $lastModified;
        }

        return false;
    }