`app.use(cache('5 minutes'))` will cache all routes, regardless of methods like `GET` and `POST`
See original GitHub issueIt 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:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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.