The Entity tag or Etag header is a new validator from HTTP 1.1 to validate the freshness of content in a browser cache with the content in web server. It ensure that the browser have the latest files in its cache.
If the browser cache have the static files, browser load that cached files instead of files from web server. Before loading files from cache, browser want to validate that files to ensure its freshness. The Etag header help to validate this freshness.
An ETag is a hash generated based on either the inode number, the last modified time and / or the size (in bytes) of a file. The default behavior in Apache web server is to use all properties to generate the ETag. So ETags provide a unique identifier for each files.
Why I want to disable Etag header?
To make a well optimized web page, it require minimum http request towards server on loading. We utilize browser caching to reduce this http requests by saving static files in browser cache memory.
When we use Etag header to validate freshness of this cached files, it make additional http request to update this static files if they are updated or modified in server. By disabling Etag header, we can reduce this additional http requests towards server.
But if we disable Etags, we force browser to rely on our Cache-Control and Expires header. So the browser never validate freshness and it rely on our expire header. So the visitor want to wait to see changes in this web pages until he clear his cache or expiry period. So I never suggest this optimization method for single server environment.
The ETags generated by Apache and IIS for the exact same component won’t match from one server to another. So when we use multiple servers to host our web site with default Apache or IIS ETag configuration, the ETag headers don’t match and the browser want to update its cache files by http request towards server on each and every page request without considering freshness.
So the Etag headers in multiple server environment (Apache or IIS) can cause broken cache mechanism for our website. This broken cache mechanism can generate slower pages, high load on server and higher bandwidth consumption.
In general, if we host our website in a single server, Etag headers are good for overall performance. They help to serve fresh content to visitors. But if we use multiple server to serve http request, disabling Etag headers can improve performance.
- Open .htaccess file.*
Add below lines of code in to .htaccess file
#BEGIN Disable ETag Header unset ETag FileETag None #END Disable ETag
- Save .htaccess file.
- Test the performance of web pages.
*You can access your .htaccess file through cPanel by clicking on the File Manager. When the popup box appears, click on the Web Root option and make sure that the “Show hidden files” option is checked.