Below are some of the available caching layers
DNS Cache
When you visit a URL, for example, www.google.com, a request is made to the DNS server to map the URL to an IP Address. The resolved IP Address gets stored in the user's web browser or the user’s OS to quickly retrieve it the next time it’s requested. This is much more efficient compared to resolving the IP Address every time you visit a website.
Client Side Cache
Client Side caching is also known as browser caching. Once the client has requested data from the server, it may store data on the browser. Client cache is efficient because it allows the browser to access data without contacting the web server, therefore, improving the latency. Clients store files after requesting them for the first time with an expiration time on the settings.
Once the files expire, the client can send a re-validation request to the server. If the server contains a newer version, re-validation fails and the server returns a full file. If the file is unchanged, the server returns a 304(Not Modified). The cache keeps the file and refreshes the expiration time. The client and server only exchange the headers information which is faster than reloading the files.
Content Delivery Network(CDN)
The browser caches most of the static content that appears on the web page to lower the load times. Browsers store the data until their time to live expires or until the memory cache is full. On the server side, various web caching techniques such as CDN(reverse proxy) can be used to improve the performance of a website. A Content Delivery Network works like a browser cache, caching content such as images, videos, and static web pages in proxy servers that are located closer to the user than the original servers.
A CDN delivers content faster because the servers are closer to the user making the request. Think of CDN as a chain of grocery stores. Instead of going to the farm where food is grown which could be miles away, a shopper goes to their local grocery store. The CDN caches the “grocery” content so pages are served more quickly. Cached content remains in the CDN as long as users continue requesting it. Examples of CDN services are Cloudflare, Amazon CloudFront, and Azure CDN.
Application Server Cache
Server-side caching utilizes key/value stores to cache data in memory. Requested data can be cached in memory instead of making requests to the database. In Memory, the cache delivers sub-millisecond response times enabling hundreds of thousands of requests per second. This is way faster than making requests to the database, therefore, reducing latency, increasing throughput, and easing the load off your relational database. Examples of Key/Value stores are Redis, Amazon’s DynamoDB, and Microsoft Cassandra.
Database Cache
A database cache layer can be applied to any relational and non-relational databases. Most databases usually include some level of caching in the default configuration. Tweaking these settings for specific usage patterns greatly improves performance.