Over a million developers have joined DZone.
Silver Partner

Caching – What is it and why is it important?

· Performance Zone

The Performance Zone is brought to you in partnership with Smartbear. Learn more about how the performance of your API's, web, and mobile applications have a direct impact on your bottom line with the Guide to Synthetic Monitoring.

Caching keeps frequently accessed objects, images and data closer to where you need them, speeding up access to websites you hit often.

Your browser is the first layer of caching, keeping images and data from websites that you visit often.  Next the webserver itself has a caching layer, typically implemented by something like memcache, caching information that it would normally fetch from the database on the backend.  This avoids the network roundtrip, and also avoids the load and work of running the query to fetch that data again.

Furthermore you can install what’s called a reverse-proxy on the webserver, such as Varnish.  This can bring further speedups and performance benefits to your overall architecture.

On the database server you also do a lot of caching.  With MySQL you may configure the query cache, which caches query result sets inside of MySQL, eliminating the need to rerun those queries on subsequent calls.  And further the database server has various other caches such as the InnoDB buffer cache, to keep blocks of data in memory, reducing slower requests from disk.

On Quora, Sean Hull asks: What is caching and why is it important?

The Performance Zone is brought to you in partnership with Smartbear. Discover how important it is to recognize the inherent power of APIs and bulding the appropriate safeguards to protect it with the Essential Guide to API Monitoring.

Topics:

Published at DZone with permission of Sean Hull .

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}