Chapter 8. Cache me if you can

This chapter covers

  • Managing client-side caching
  • Introducing Catbox
  • Server-side caching with hapi

There are two things that we always want to do in web applications:

  • Give users the most up-to-date, relevant data that we can get our hands on
  • Make the experience as quick as possible

We can’t always have both at the same time, so we find a compromise. Caching is the name of that compromise. Caching lets us serve data that is fresh enough, with the benefit that we can serve it a lot faster. It’s common sense, and sometimes this isn’t much of a compromise to make as figure 8.1 illustrates—in particular, when your data changes infrequently.

Figure 8.1. The server-side caching trade-off

It’s faster to serve ...

Get hapi.js in Action now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.