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.

`app.use(cache('5 minutes'))` will cache all routes, regardless of methods like `GET` and `POST`

See original GitHub issue

It turns out if we do app.use(cache('5 minutes')), it will cache all routes, regardless of methods like GET and POST. However, for methods like PUT and POST, in many cases this implied update on the server side and shall not be cached. Should we add documentation or functionality to make supporting such case more easily?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
killdash9commented, Aug 15, 2019

I don’t think that PUT,PATCH,DELETE should ever be cached. POST is a gray area because the SOAP protocol uses POST for everything, although that technology is on the way out.

It could be built to ignore POST (and PUT,PATCH,DELETE) in the app.use(cache(…)) pattern, and if anyone needs post caching they could add it on the route explicitly. This seems like a good default behavior. It does sound like a “fixing expected behavior” fix to me.

1reaction
svozzacommented, Aug 16, 2019

Something I would say is that I’ve used GraphQL APIs where the request was submitted as a POST request but I’m not sure how common that is.

Read more comments on GitHub >

github_iconTop Results From Across the Web

In-Memory Caching in ASP.NET Core - Code Maze
In-Memory Caching in ASP.NET Core is the simplest form of cache in which the application stores data in the memory of the webserver....
Read more >
Django's cache framework
This argument defaults to 300 seconds (5 minutes). You can set TIMEOUT to None so that, by default, cache keys never expire.
Read more >
Caching in Python Using the LRU Cache Strategy - Real Python
Caching is an optimization technique that you can use in your applications to keep recent or often-used data in memory locations that are...
Read more >
Asp.net 7 Output Caching - Cache by route, with other routes ...
typically you don't cache posts. the post body is not part of routing, so it can not be used to effect the cache....
Read more >
RFC 7234: Hypertext Transfer Protocol (HTTP/1.1): Caching
This document defines HTTP caches and the associated header fields that control ... If the request method is GET, the response status code...
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