Got Overwriting cache with 304 response
See original GitHub issuewith got 8.2.0
got.stream(imgUrl, { cache: keyv }).pipe(res);
records in mongodb:
{ "_id": ObjectID("5ab084465a793ecc436a7849"), "key": "cacheable-request:GET:https://farm2.staticflickr.com/1521/26180297656_675e75a2ce_h.jpg", "value": "{\"value\":{\"cachePolicy\":{\"v\":1,\"t\":1521635364661,\"sh\":true,\"ch\":0.1,\"imm\":86400000,\"st\":200,\"resh\":{\"date\":\"Wed, 21 Mar 2018 12:29:24 GMT\",\"connection\":\"close\",\"expires\":\"Wed, 28 Mar 2018 12:29:24 UTC\",\"cache-control\":\"max-age=604800,public\",\"via\":\"http/1.1 pc-pool116.flickr.gq1.yahoo.com (ApacheTrafficServer [cMsSfW])\",\"server\":\"ATS\",\"x-photo-farm\":\"2\",\"x-photo-farm-guess\":\"2\",\"access-control-allow-origin\":\"*\",\"access-control-allow-methods\":\"POST, GET, OPTIONS\"},\"rescc\":{\"max-age\":\"604800\",\"public\":true},\"m\":\"GET\",\"a\":true,\"reqh\":null,\"reqcc\":{}},\"url\":\"\",\"statusCode\":304,\"body\":\":base64:\"},\"expires\":null}", "expiresAt": null }
Issue Analytics
- State:
- Created 6 years ago
- Comments:55 (27 by maintainers)
Top GitHub Comments
Thanks for looking into this @UltCombo, really appreciate that.
I’m not sure if we should try and patch things up by setting what we think the server means to respond with.
If the server isn’t following the spec then it might be getting other things wrong and it’s possible that it shouldn’t even be returning a 304.
If this issue causes the cache to be updated with an empty response then it must be this check returning false: https://github.com/lukechilds/cacheable-request/blob/master/src/index.js#L82-L88 which happens inside the
http-cache-semantics
lib. If we decide to work around this, it should be handled there. (pinging @kornelski just so you’re aware)See if @kornelski is interested in handling this scenario. If not, thanks for sharing your solution, it’ll be helpful for anyone else who comes accross this.
cacheable-request@6.0.0
published which I think should resolve this. I’d be grateful if anyone who was encoutnering the issue could test this.