Fastest way to cache for lazy developers: Angular with RxJS

Click for: original source

Dler Ari is author of this piece about HTTP caching and Angular. HTTP caching simply means the browser stores local copies of web resources for faster retrieval the next time the resource is required, thus reducing the number of server calls.

The aim of this article is to show how you can implement caching with only two RxJS operators: publishReplay() and refCount().

The topics covered include:

  • What is caching?
  • Caching with RxJS + two operators
  • A practical example of how to cache
  • Summary

Caching is a viable choice if we want to save numbers of server requests, especially for data that rarely changes such as daily, weekly etc. However, one should always be cautious when dealing with caching and don’t overdo it. Easy!

[Read More]

Tags angular nodejs javascript