NodeJS, Express, Redis, Redis Cluster, TypeScript, Mustache, Gulp
TypeScript JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This is an example project showing how to setup a project using NodeJS, Express, Redis, Redis Cluster, TypeScript, Mustache and Gulp.

Caching is a very important aspect of webdevelopment and nearly all high-traffic server applications use caching to be able to reliably serve their content. This example project is created as part of my research on how to use a clustered Redis in combination with a NodeJS/Express server application. I've also taken the liberty to use TypeScript as my supporting dialect because I like the syntax of exporting/importing modules better than the "Node"-way. And I believe it makes developing monolith applications easier with better IDE support.


  • TypeScript
  • Gulp
  • NPM
  • NodeJS
  • Redis Cache


  1. Run npm install to install all the required dependencies.
  2. Copy src/redis/credentials.example.ts to src/redis/credentials.ts.
  3. Edit src/redis/credentials.ts so the host value points to your own Redis instance.
    1. Optionally if you use a Redis Cluster you can edit src/redis/redis.ts and change
    //client: redisClustr,
    client: redisClustr,
  4. Build the project
    1. Run gulp to build the project.
    2. Run gulp watch to build the project and keep a watch on the project files and compile them on any changes.
  5. Start the server with:
    1. Windows: npm run devw
    2. *ux: npm run dev


  • Navigate to http://localhost:3333 to see the generated webpage (~100KB).
  • Navigate to the same page again to see the website served from the Redis cache.
  • Navigate to http://localhost:3333/invalidate to invalidate the Redis cache.


On a laptop with Core i7-5500U, 8GB Ram, SSD HDD running Windows 10:

  • Generating the webpage costs ~40ms to ~50ms.
  • Serving the website from a locally installed Redis cache reduces that amount to ~20ms.

On a high-traffic webserver one can make the assumption that generating the website might take longer than ~40ms. And operations like calling other webservices or querying a database will add to that time as well.

If you happen to have your Redis Cache installation on a separate server from your webserver then you have to take network overhead into consideration. You may find that sometimes it makes little difference or in rare cases worsen the ttfb if you for instance retrieve data from your database again and again with each page load compared to fetching an already cached webpage from a remote Redis Cache.