Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up`app.use(cache('5 minutes'))` will cache all routes, regardless of methods like `GET` and `POST` #170
Comments
|
@killdash9 @svozza Thoughts on this? I agree that probably only GET should be cached, and am happy to put that check in, but for the following:
|
|
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. |
|
+1 to @killdash9 |
|
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. |
|
In my case I like that the POST is also being cached. Here is an example of my experience with this: I have some trigger that posts to
|
|
Not sure it's really an issue, just apply the cache middleware to the method functions (ie. app.post) and not the route ones (app.use) you dont have to explicitly handle 404s etc then express will do it. |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

It turns out if we do
app.use(cache('5 minutes')), it will cache all routes, regardless of methods likeGETandPOST. However, for methods likePUTandPOST, 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?