This post aims to explain some of the ways in which caching of data in systems communicating over HTTP is achieved, and how to implement the different forms of caching in a web application created using ASP. Broadly speaking (and that’s the level I intend to stay at), caching in HTTP can be categorised into two models - expiration and validation.
The fastest way for a system to retrieve data over the network is not to do it at all!
This header value can be used in the absence of a header.
When a resource is more volatile and subject to change, another way of reducing unnecessary network traffic is to provide metadata about that resource, which can be used to determine whether the data has changed at some later date.
Note that when using cache validation, you will often combine it with expiration too: using expiration for a few seconds/minutes/hours (depending on the timeframe in whihc you consider serving the old content is fine), and validation to avoid redoing all the backend work but only part of it when the cache expires if there has been no change. I now understand that if the request from varnish to the backend AFTER the content expired will return NOT Modified, then varnish will just reuse the old cached version.
So the e Tag is just something supplied through the request to enable the checking in symfony which should ideally be faster than recomputing the whole page.
The ETag is sent by the server as HTTP response header.If a client has previously requested and received an up-to-date copy of a particular resource, it shouldn’t have to perform the round trip to the server to re-retrieve the same data, but instead serve up the existing cached information.Here’s an excerpt from the HTTP/1. on cache expiration: HTTP caching works best when caches can entirely avoid making requests to the origin server.The ETag was introduced to provide a more flexible mechanism for validating entities than the last-modified date.If for example a component is different based on the User-Agent or Accept-Language headers, the state of the entity can be reflected in the ETag.On subsequent page views, the cached components are read from disk on the condition that they are still “fresh”.