How to improve performance through Caching?

Arun Rajeevan
2 min readMar 11, 2022

--

Server Side Caching

A good example by AWS Document: Link

1) Remote caches

A remote cache (or side cache) is a separate instance (or separate instances) dedicated for storing the cached data in-memory.
Remote caches are stored on dedicated servers and are typically built on key/value NoSQL stores, such as Redis and Memcached.
They provide hundreds of thousands of requests (and up to a million) per second per cache node. Many solutions, such as Amazon ElastiCache for Redis, also provide the high availability needed for critical workloads.

With remote caches, the orchestration between caching the data and managing the validity of the data is managed by your applications and/or processes that use it. The cache itself is not directly connected to the database but is used adjacently to it.

Two common approaches are cache-aside or lazy loading (a reactive approach) and write-through (a proactive approach).

  1. In Reactive approach, cache is updated after the data is requested.
    Advantage:The cache contains only data that the application actually requests, which helps keep the cache size cost-effective.
    Disadvantage: Longer initial response time because the data is loaded after first miss.
  2. In Proactive approach, cache is updated immediately when the primary database is updated.
    Advantage: Since cache is up-to-date with the primary database, there is a much greater likelihood that the data will be found in the cache. This, in turn, results in better overall application performance and user experience.
    Disadvantage:A disadvantage of the write-through approach is that infrequently-requested data is also written to the cache, resulting in a larger and more expensive cache.
  3. With both approaches, the application is essentially managing what data is being cached and for how long.

A proper caching strategy includes effective use of both reactive and proactive loading of data and setting an appropriate expiration for the data to keep it relevant and lean.

Client Side Caching

  1. Browser level:
    Images, HTML code, stylesheets and Javascript libraries
  2. Network request/response:
    Put api requests-response as key value pair in browser or app local storage.
    Use libraries or frameworks for having such local cache.

--

--