Get the latest tech news
ETag and HTTP Caching
One neat use case for the HTTP ETag header is client-side HTTP caching for GET requests. Along with the ETag header, the caching workflow requires you to fiddle with other conditional HTTP headers like If-Match or If-None-Match. However, their interaction can feel a bit confusing at times. Every time I need to tackle this, I end up spending some time browsing through the relevant MDN docs123 to jog my memory. At this point, I’ve done it enough times to justify spending the time to write this.
If they don’t match, the server responds with a 200 OK status, including the new content and a new ETag header, prompting the client to update its cache. If the client is a browser, it’ll automatically manage the cache and send conditional requests without any extra work. Crossing the CORS crossroad Dysfunctional options pattern in Go Einstellung effect Strategy pattern in Go Anemic stack traces in Go Retry function in Go Type assertion vs type switches in Go Patching pydantic settings in pytest Omitting dev dependencies in Go binaries Eschewing black box API calls
Or read this on Hacker News