Use Cases of Caching Streams

Explore the use cases of caching streams.

Optimizing the HTTP requests

The first use case is optimizing the HTTP requests in order to enhance the performance of our web applications. All that you have to do is put the result in a cache that’s a shared place for all the consumers.

Accounting for expensive side effects on the streams

There’s another use case where caching streams makes a lot of sense: when accounting for expensive side effects on the streams. In general, we refer to the actions executed after a value is emitted as side effects. This could be logging, displaying messages, doing a kind of mapping, and so on. Here’s an example of a side effect of using the tap operator:

Get hands-on with 1200+ tech skills courses.