question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Got Overwriting cache with 304 response

See original GitHub issue

with 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:closed
  • Created 6 years ago
  • Comments:55 (27 by maintainers)

github_iconTop GitHub Comments

3reactions
lukechildscommented, Dec 24, 2018

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.

2reactions
lukechildscommented, Jan 4, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Got Overwriting cache with 304 response · Issue #28 · jaredwray ...
It seems it has cached 304 response for third request, with no body, and returns that. And this does happen consistently. I presume...
Read more >
How to prevent request that returns 304 - Stack Overflow
After clearing my cache the new policy was applied and now the file is served directly from memory/disk cache as expected. Save this...
Read more >
How to Fix the HTTP 304 Not Modified Status Code - Kinsta®
The HTTP 304 not modified status code indicates a communication problem between a user's browser and a website's server.
Read more >
Understanding HTTP/304 Responses - Telerik
A web server sends a HTTP/304 in response to a Conditional Validation request, indicating that the client's copy of a resource is still...
Read more >
304 Not Modified - HTTP Status Code Glossary - WebFX
Since the goal of a 304 response is to minimize information transfer when the recipient already has one or more cached representations, a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found