blog logo
[ultimatesocial count="true" networks="linkedin,facebook,twitter" url="" skin="minimal"]

How It Works: Cache

Ben Bachtler • December 14, 2017

Whenever there’s an issue with a website, one of the first suggestions is always, “did you clear your cache?” So, what exactly is this nefarious cache? What does it do? What is it good for? In this edition of “How It Works,” I’m going to clear that up for you.


What is Cache?

Simply put, cache (pronounced cash) is a collection of grouped data that is saved in the short term for quick access. Across hardware and software, the short-term access concept remains the same.

Here’s an analogy: Let’s pretend that you live in an apartment in the city and need to do laundry. The only problem is, your complex doesn’t have machines. What a drag. Every time you need to do laundry, you’ll need to travel blocks away and spend an annoying amount of time accomplishing a very basic task. Now, what if your unit had a machine? Needless to say, the whole process would be a heck of a lot quicker. In this scenario, going to the laundromat represents the time and effort needed to retrieve data from its original source (i.e. a hard drive). Conversely, having a machine in your unit would represent cache. It enables you to do laundry/retrieve data in a much faster way.


How Cache Works

To expand a little further, it would stand to reason that the more often cache is used, the faster data can be retrieved. That makes sense, but what happens when requested data is NOT cached? How does this whole system actually work? It’s based on data hits and misses.

When a data request is made, the first step is to check the cache. Since this is essentially a block of similar data, the desired data may or may not be there. If it is, then we have a “hit,” and the data is quickly rendered.




If the data is not found, then we have a cache miss. On a miss, the request is passed onto the original data source. The requested data is then served to the client, but also is cached as well for future use. Caches are updated via a replacement policy. For example, one popular replacement policy, “least recently used”, replaces the least recently used entry with the latest “miss.” So, in a sense, the cache stays updated with the most frequent and recent requests. 




How Cache Helps

More broadly, cache can be tied to an overarching concept of size vs speed. A hard drive, for example, may be able to contain a very large amount of data. Since it is so large, though, it takes time to find the needed data. Comparatively, since caches are much smaller, data requests take substantially less time to complete. Scope is limited, but caches enable sites to render popular content extremely quickly. In eCommerce, fast load times are critical to customer engagement.

It is also worth mentioning that cache is not restricted to hardware. For example, web pages often put the system to use. Instead of having to load images from a server every time you visit the same page, this information can be cached. Then, each time the page is revisited, those images are “remembered” for prompt display.

At the end of the day, even though we are often told to clear it to troubleshoot web issues, cache is something we can all be thankful for. It speeds up our daily processing and allows for an efficient, effective user experience.

Ben Bachtler

About the author

Ben Bachtler

Ben Bachtler is an Applications Engineer out of LYONSCG's Chicago office. Specializing in front-end development, Ben builds high-quality sites that drive engagement and conversion for clients.

Subscribe to our blog

Let's discuss the next step in your commerce journey.

XSchedule a meeting