A CDN improves performance by caching content from origin servers at regional edge locations. When a user requests content through a CDN, if the content is cached nearby it delivers a "cache hit" from the edge server, otherwise it's a "cache miss" and the content must be retrieved from the origin server. Increasing the cache hit ratio is important to reduce latency and server load. Strategies to improve the ratio include optimizing cache control headers, ignoring cookies and query strings, and storing frequently requested content.
3. The request needs to travel from the client
to the origin server that hosts the web app
via a protocol. To do this, the request
becomes fragmented and
encapsulated into data packets, and is
then sent out across the internet’s
backbone — a network of cables.
4.
5.
6. Signals, therefore, have to
traverse such vast distances
twice in order to provide a
complete response. There will
also be server-side delays
due to load.
7. This is a big reason for network
latency today and it is a big no-
no for websites and web
applications that want to be
competitive. Even a few seconds
of latency might result in a bad
user experience and lead to user
churn.
8. Today, most leading service
providers use CDNs to deliver
content to their users. A CDN does
this via multiple improvements over
a single-server setup: by
optimizing file storage,
deploying better hardware to
store and process requests, and
most importantly, using cache
storage.
11. Caching is the process by which a
file gets stored in a temporary
storage location. CDN servers
cache HTML scripts, JavaScript,
and images from the origin
servers in proxy servers to reduce
latency.
12. When the browser (user) requests
information from a website through a
CDN service for the first time, the CDN
delivers the content by connecting to the
origin server and then caching the content —
essentially saving the content in the nearest
data center to the user.
So, when users request the content in the
future, the content is served from the cache,
which makes the whole process of content
delivery faster.
13. After a TCP handshake is made,
the client machine will make an
HTTP request to the CDN. In case
the content has not yet been
cached, the CDN will make the
request to the origin server, and
then download the content from the
origin. This results in an additional
request between the origin server
and the CDN’s edge server.
16. Basically, the successful access of the
requested piece of data in the CDN’s
cache memory is referred to as a hit.
If a browser requests a piece of
content and the CDN has it cached,
then it will deliver that content.
This is referred to as a cache hit.
17. However, if the content is not available,
then the CDN makes the request to the
origin server.
This is classified as a cache miss.
When the requested content is not
available in the cache, this leads to a
delay in the delivery of the requested
content.
19. In a nutshell, high cache hit ratios
result in faster web apps, while low
cache hit ratios result in slower web
apps. This increases the stress on the
origin server, as well as increased
latency and dropped connections.
Caching is an integral part of
what a CDN does.
21. How to Increase Cache Hit Ratio?
Optimise cache-control headers: The Cache-Control
header field specifies directives for caching mechanisms in
cases of requests and responses. These headers are used
to set properties, such as the maximum age of an object,
expiration time, or whether or not an object is to be cached
at all.
Depending upon how frequently your content changes, you
need to specify this property. Optimising these property
values can help improve the number of cache hits on your
CDN.
22. How to Increase Cache Hit Ratio?
Ignore cookies: Cookies tend to be un-cacheable,
hence the files that contain them are also un-cacheable.
Therefore, it’s important that you set rules. For example,
ignore all cookies in requests for assets that you want to
be delivered by your CDN.
23. How to Increase Cache Hit Ratio?
Ignore query strings: Query strings are useful in multiple
ways: they help interact with web applications and APIs,
aggregate user metrics and provide information for objects.
The problem arises when query strings are included in static
object URLs.
In this case, the CDN mistakes them to be unique objects and
will direct the request to the origin server. Accordingly, each
request will be classified as a cache miss, even though the
requested content was available in the CDN cache. This leads
to an unnecessarily lower cache hit ratio.
24. A well-implemented CDN cache will
optimise your infrastructure costs,
effectively distribute resources,
and deliver maximum speed with
minimum latency.
25. By the way, Black Friday is just around the corner.
Get in touch with us to try Medianova CDN for
free for 14 days to make sure you website is
100% Up and Running during the holidays!
Yes, Get Me in Contact With You!