StalkR / httpcache

http RoundTripper providing persistent and volatile cache
https://godoc.org/github.com/StalkR/httpcache
Apache License 2.0
21 stars 4 forks source link

[Feature] - ETag if-modified cache invalidation #4

Open brendanjerwin opened 8 years ago

brendanjerwin commented 8 years ago

Would it make sense handle Etags for cache invalidation in the same way a browser might?

StalkR commented 8 years ago

Hi Brendan, not really: the goal for this library is to cache everything, even requests that the server do not intend to be cached (cf. https://github.com/StalkR/httpcache/blob/master/cache.go#L59 that caches all 200 and 301). It's not meant as a caching mechanism like in browsers. I created it primarily to test libraries fetching pages and parsing them so that tests would only fetch it once, then re-use the same page in following runs of the tests, this way testing only just the parsing code (e.g. https://github.com/StalkR/imdb/blob/master/init_test.go). So I'd recommend creating another library for this, but feel free to fork and evolve this one if you think it's a good basis! Cheers