About the HTTP response header field X-Cache-Akamai

The author's set of step-by-step learning tutorials for SAP UI5 developers introduces the development steps of SAP UI5 applications. After running these applications, a request Response Header field named X-Cache- Akamai, the value is head, which represents the cache status information of Akamai Content Delivery Network (CDN).

This article explains the meaning of this HTTP header field in detail, and illustrates it with examples.

  1. About the Akamai Content Delivery Network (CDN):
    Akamai is the world's leading provider of a CDN, a network of servers located around the globe that stores and delivers website content. When a user visits an Akamai CDN-enabled website, the request is forwarded to the Akamai server closest to the user, resulting in faster content delivery and improved website performance and reliability.

  2. X-Cache-Akamai field in Response Header:
    When the website enables the Akamai CDN service, the Akamai server will add a field called X-Cache-Akamai to the HTTP response header (Response Header) to provide information about the request information about the state of the cache.

  3. Value of the X-Cache-Akamai field:
    The value of the X-Cache-Akamai field describes how the Akamai server caches the current request. In your case, the field value is head, which is a cache flag used by Akamai to indicate that the response headers for this request have been cached, but the response body has not.

To illustrate:
Suppose there is a website named example.com with Akamai CDN enabled, and a user enters the URL "http://example.com" into a browser and visits the website.

  1. First visit:
  • The first time a user visits the site, the browser sends a request to the example.com server.
  • Since this is the user's first visit, the Akamai servers have not yet cached the site's content.
  • The server returns the response header to the browser and adds it to it X-Cache-Akamai: miss, indicating that the response header of this request has not been cached ( missindicating a cache miss).
HTTP/1.1 200 OK
Date: Wed, 27 Jul 2023 12:00:00 GMT
Server: Apache
X-Cache-Akamai: miss
  1. Second visit:
  • The user visits "http://example.com" again.
  • At this point, the Akamai server has cached the response headers from the previous request.
  • The server adds it to the response header X-Cache-Akamai: hit, indicating that the response header of this request has been cached ( hitindicating a cache hit).
HTTP/1.1 200 OK
Date: Wed, 27 Jul 2023 12:05:00 GMT
Server: Apache
X-Cache-Akamai: hit
  1. Some content updates:
  • Now something on the "example.com" site has been updated, such as an image on the homepage.
  • The user visits "http://example.com" again, and the browser sends a request to the Akamai server.
  • Since response headers usually don't change frequently, Akamai servers still use the cached response headers and therefore still return them X-Cache-Akamai: hit.
  • However, since the response body has changed, the Akamai server will return the new image content in the response body and add in the response headers X-Cache-Akamai: fresh, indicating that the response body is fresh because it has been updated.
HTTP/1.1 200 OK
Date: Wed, 27 Jul 2023 12:10:00 GMT
Server: Apache
X-Cache-Akamai: hit
  1. Force refresh:
  • The user performed a forced refresh in the browser, or pressed the Ctrl + F5 keys, intending to skip the cache and get the latest content.
  • The browser sends a Cache-Control: no-cacherequest to the Akamai server with the request header.
  • The Akamai server ignores the cache and requests the latest content from example.com's origin server.
  • The server returns completely new content, added in the response headers X-Cache-Akamai: fresh.
GET / HTTP/1.1
Host: example.com
Cache-Control: no-cache

HTTP/1.1 200 OK
Date: Wed, 27 Jul 2023 12:15:00 GMT
Server: Apache
X-Cache-Akamai: fresh

Summarize

X-Cache-AkamaiWhen you see the value of the Response Header field of a request in the Network panel of Chrome Developer Tools head, it means that Akamai CDN has cached the response header of the request, but the response body may not be cached. This mechanism allows the Akamai CDN to process requests more efficiently, improve website performance, and fetch the latest content by requesting the origin server when necessary.

Guess you like

Origin blog.csdn.net/i042416/article/details/131974609