In my Node-Express app I'm using Postgre as main data and Redis as cache system.
When a visitor request an url, my app request the json to Redis. If isn't available, make a request to Postgre, save the json to Redis and then render the EJS template. The next request to the same url, I get the json from Redis and render the template.
Now I want to save to Redis the full rendered template instead of json to save CPU usage. I tried this trick but it did not work:
Any ideas or suggestions how to do it ??
Thanks in advance for your help.
The Express API reference shows that res.render() accepts a callback as the last argument. That callback is called with (err, html), so just pass in a callback and store the (string) html into redis.