Search code examples
httphttp-caching

Is it OK for several paths to share the same ETag?


I run a real-time image resizing server, that acts as a proxy between the browser and the server owning the original image:

Browser <=> Resize server <=> Origin server

I can request an image on the resizing server, with different parameters:

/images/kitten.jpg?w=400&h=300
/images/kitten.jpg?w=800&h=600

Both requests will fetch the same file /images/kitten.jpg on the origin server, but yield a different version (size) of this image.

Now I want to implement caching. Say the origin server sends an ETag header:

ETag: "13456789abcdef"

If I just forward the unmodified ETag along with my resized image, the browser will cache two different images, on two different paths, with the same ETag.

Now I can happily forward any If-None-Match header from the browser to the origin server, and react to a 304 Not Modified by responding with a 304 in return.

But could it be a problem when two paths on my web server, serving different content, share the same ETag?

I've implemented it successfully so far, everything seems to work as expected. I just want to be sure that I have not overlooked something, and that there is no side effect of having several paths sharing the same ETag in the browser's cache.


Solution

  • No, it's not a problem. ETags are per request URI.