this code I am using to set etag in header, I am able to set etag in response header but If-None-Match always coming empty. 1. Nginx Server 2. Magento Version – 2.4.8-P1
$etag = md5($category->getId();
$etagHeader = 'W/"' . $etag . '"';
$this->response->setHeader('Etag', $etagHeader, true);
$this->response->setHeader('Cache-Control', 'public, max-age=3600', true);
$this->response->setHeader('Pragma', 'cache', true);
if (trim($this->request->getHeader('If-None-Match')) === $etag) {
$logger->info('ETag matches, returning 304');
$this->response->setHttpResponseCode(304);
$this->response->clearBody();
}