Question: The difference between 123 ms and 11 ms is rather miniscule so why even bother enabling the cache?

Answer: Because we are dealing with only one file. If we have a 100 resources and each takes an additional 100 ms to load the cost starts to add up. This negatively impacts the user experience and even small delays in page load time can lead to users abandoning a website.

The client's perspective

When a browser needs to load a resource, such as an image file, it follows a sequence of steps to determine where to get the file:

  1. Check the Memory Cache: The browser first checks its memory cache. This is used for resources downloaded in the current browsing sessions (since memory is non-persistent).
  2. Check the Disk Cache: If the resource isn't in the memory cache, the browser checks the disk cache, a more persistent cache that contains resources from sites visited in the past.
  3. Network Request: If the resource isn't in either the memory or disk, the browser makes a network request to the server hosting the resource.

When a cached file is found, this is known as a cache hit. When a cached file is not found, this is known as a cache miss.

It should also be noted that data could be cached and we could still have a cache miss. This data might be stale and the cache might have expired.