4

I use ETags to improve performance. I decided to use an Etag that is valid on Server, Client and Proxy.

But how is this handled if the proxy has saved the ETag? Does the Proxy still ask the website if the ETag is valid or does the proxy itself just answers "I know this one. No need to ask the server?"

Or in other words, does the following scenario still work if ETag-Caching on Proxy is enabled?

  1. Browser does a request. An ETag "ABBA" is returned
  2. Browser does another request to the server. The ETag "ABBA" is recognized, a 304 is returned 2.1 Browser uses local cache
  3. Browser does another request to the server, sending the ETag "ABBA". This time the Server decides that the data has changed, Therefore it returns a new Response with a new Etag.

If between the client and the server there is a proxy that knows the ETag, does it still ask the server if the Etag is valid or does the request end there if the Proxy once knows the etag?

1 Answers1

3

The behaviour of the proxy server is mostly controlled by your Cache-Control header as set by the back-end server.

As long as the resource has not expired the proxy will serve it (including all the associated meta-data such as the ETag) from cache. The proxy does not need to contact the server to validate the original content as long as it as allowed to keep the resource in cache.

Once the Cache-Control header dictates that the resource should expire from the cache, or be revalidated, the proxy server will contact the server again to validate the original resource. If the ETag has not been modified on the server, it does not have to be downloaded again, the same object (but with updated Cache-Control timings) can remain in cache.

This resource may be of interest.

HBruijn
  • 72,524
  • 21
  • 127
  • 192