Express' app.param still executes if route is cached
dustinmartin opened this issue · 1 comments
dustinmartin commented
Thanks for making this library! Really great stuff.
I'm running into an issue though where I have an Express param that is bound to a method that loads some data prior to the route
app.route('/user/:userId')
.get(cache.route(), controller.getUserById)
app.param('userId', controller.loadUser);
What I'm seeing is that even though the route is cached it still runs the param method which loads the data from the database and slows down the route.
Any ideas how to get around this? Thanks.
corbanb commented
We solve this by doing a solve of:
app.route('/user/:userId').get(cache.route(), controller.loadUser, controller.getUserById)
or the likes.