Web-server – Etag configuration with multiple apache servers or CDN / How does Google do ETags

apache-2.2cdnstatic-contentweb-server

I have an application which is served from two apache2 servers and I want to configure the ETags on static content. In the future I would also like to use a CDN. I see that this is supposed to be a problem because the Etag information will be different from server to server…

The ETag format for Apache 1.3 and 2.x
is inode-size-timestamp. Although a
given file may reside in the same
directory across multiple servers, and
have the same file size, permissions,
timestamp, etc., its inode is
different from one server to the next.

So if you're using more than one webserver to host your app (like 90% of the webapps you use everyday do), it's supposed to be an issue. However I see Google uses Etags, and certainly they use multiple servers and CDN and edge caching, etc… I get a 304 response for any cached Google content. How do they do it? How do you get around the multiple server issue? Is there a way to configure this with Apache?

Best Answer

You can configure Apache so it doesn't use the inode as part of the hash. See the FileETag directive.

Related Topic