Caching
This section can help you understand when downloads are cache hits and how to determine the number of bytes served from cache.
Objects served from cache
This section assumes that the object is cacheable
. For non-cacheable
objects, the cacheable
and cache hit
parameters
return 0.
In general, if an edge server doesn't got forward with the request and serves a 2xx response, it's safe to assume that the object was served entirely from the cache. When partial object caching is enabled for the object, you can consider the download a cache hit only if an edge server doesn’t go forward to fetch any of the fragments needed to satisfy the request.
- Successful If-Modified-Since (IMS) validation for objects without partial object caching
- Successful partial object caching master/fragment check
If the edge server goes forward to fetch the object, and the forward server returns a
304 status code (not modified), the edge server still serves the object from cache.
You can consider the download a cache hit. However, if the forward server returns a
20x status code, the edge server evicts the content in cache and replaces it with
the updated object. You can consider the download a cache miss. Note that the
updates on the If-Modified-Since
header are considered a cache hit
as the content body is served from cache.
When a POC master entry needs to be checked, the edge server forwards a 0-0 range
request to the origin. It checks again the object size based on the
Content-Length
value included in the
Content-Range
header. If the check fails, the edge server
fetches the updated object. This is a cache miss.
When a POC fragment needs to be checked, the edge server forwards a one-byte range
request that starts from the fragment's offset. It checks again the fragments size
based on the Content-Length
value included in the
Content-Range
header. If the check fails, the edge server
fetches the complete fragment. This is a cache miss.
If all POC check requests are successful, the download is a cache hit even though the edge server forwarded the check requests.
Bytes served from cache
This section assumes that the object is cacheable
. For non-cacheable
objects, the cacheable
and cache hit
parameters
return 0. Also, the bytes_from_cache
value from the cache
stats
returns 0.
For objects without partial object (POC) caching enabled, either none or the entire
object comes from cache. However, for POC-enabled objects, some fragments may
already be in cache, and the edge server needs to go forward to fetch the rest of
the needed fragments. At the end of the download, the cache stats
parameter returns the number of cached fragments multiplied by the requested
fragment size in its bytes_from_cache
value and the total number of
fragments multiplied by the requested fragment size in its
total_bytes_to_client
value.
For example, if two fragments are in cache for an object split into 10 fragments,
each consisting of 2000 bytes, the cache stats
parameters returns
4000/20000
.