Mar articles related to web optimization
Entity tags (ETags) are a mechanism that servers and browsers use to determine if the component stored in the browser cache matches that of the origin server.
(An "entity" is another word, a "component": images, scripts, style sheets, etc.) ETags have been created to provide a mechanism for validating entities, which is more flexible than the modification date. An ETag is a string that uniquely identifies a specific version of a component. The origin server specifies the component using the "ETag" header.
HTTP/1.1 200 OK
Last-Modified: Tue, 12 Dec 2006 03:03:59 GMT
Then, if the browser needs to validate a component, it uses the "If-None-Match" header to pass the ETag back to the origin server. If the ETag sent returns a 304 code, it is returned reducing the response by 12195 bytes for this example.
GET /i/midominio.gif HTTP/1.1
If-Modified-Since: Tue, 12 Dec 2006 03:03:59 GMT
HTTP/1.1 304 Not Modified
The problem with ETags is that they are generally built using the attributes that make it unique for a certain site hosted on the server. ETags will not match when a browser obtains the original component from one server and then tries to validate that component on a different server, a situation that is very common on websites that use a group of servers to handle requests. By default, both Apache and IIS embed data in the ETag which dramatically reduces the chances of successful validity testing on multi-server websites.
The ETag format for Apache 1.3 and 2.x is "inode-size-timestamp". Although a certain file can be in the same directory across multiple servers, and have the same size, permissions, date, etc., its inode is different from one server to another.
IIS 5.0 and 6.0 have a similar problem with ETags. The format for ETags in IIS is "Filetimestamp: ChangeNumber". A "ChangeNumber" is a counter used to keep track of changes in IIS configuration. The "ChangeNumber" is unlikely to be the same across all web sites hosted on an IIS server.
The end result is an ETags generated by Apache and IIS for the same component that will not match from one server to another. If the ETags do not match, the user does not receive the small 304 response that the ETags have designed; instead, you will get about 200 normal responses with all the component data. If you host your website on a single server, this is not a problem. But if you have multiple servers to host your website, and you are using Apache or IIS with the default ETag settings, your users will see increasingly slow pages, your servers will be overloaded, you will be consuming a lot of bandwidth, and proxies will not be caching the content efficiently. Even if your components have a long-lived "Expires header", a conditional GET request is still performed as long as the user presses Reload or Refresh.
If you are not taking advantage of the flexibility that the ETag validation model provides, it is best that you simply remove the ETag completely. The "Last-Modified" header validates based on the component's timestamp. And removing the ETag reduces the size of the HTTP headers, both in response and subsequent requests. In Apache it is really simple, we just have to add the following line, in our Apache configuration file:Date update on 2020-11-13. Date published on 2020-11-13. Category: Computer class Author: Oscar olg Fuente: tecnologia