I am creating application which has dynamic several parts, like
- header
- menu 1
- menu 2
- content
- sidebar
- footer
Each part is fetching value from the database. right now what happened is when my page loads it is querying database to fetch the menu1, menu2, sidebar and footer, but which is actually fixed, and do not need database request once it loaded. here is the sudo code.
router.get('/', function(req, res, next) {
/*get menu 1*/
/*get menu 2*/
/*get menu content*/
/*get menu sidebar*/
/*get menu footer*/
/*render template*/
}
I am beginner to nodejs, can any one light up how can I save the database request? sample code will be helpful.