How Caching Affects Request Handling

The logic through which requests for content are handled by the CDN is illustrated below.

Upon receiving a request for content, an edge server will check to see whether it has a cached version. If it finds a cached version of the requested content, it will calculate the asset's time to live (TTLTime to Live. Refers to the amount of time that a cached asset is still considered fresh. Our edge servers will continue to serve a cached version of an asset while its TTL has not expired. An asset's TTL is calculated by the Cache-Control and Expires headers associated with the response sent by the origin server.) according to its Cache-Control and Expires headers. This TTL determines whether the cached version of the requested content is fresh or stale.

Cache State Action(s)
FreshIndicates that the requested content has been previously cached and its TTL has not expired. An edge server will immediately serve the requested content to the HTTP client.

StaleIndicates that the requested content has been previously cached and its TTL has expired.

An edge server will perform either a standard or conditional GET request to the CAN gateway server depending on whether the cached asset contains Last-Modified and/or ETag directives.

  • If the CAN gateway server has it in cache and it is fresh, then it will serve the cached version to the client via the edge server.
  • If the CAN gateway server has it in cache and it is stale, then it will perform either a standard or conditional GET request to the origin server depending on whether the cached asset contains Last-Modified and/or ETag directives.
  • If the CAN gateway server does not have a cached version of it, then it will perform a standard GET request to the origin server.
Not CachedIndicates that the edge server did not find a cached version of the asset.
  1. An edge server will forward the HTTP client's request to the CAN gateway server.
  2. The CAN gateway server determines how to handle the request according to the cache state of the requested content.

    • Fresh Content: The CAN gateway server will respond with the cached version of the content to the user via an edge server. Skip to step 4.
    • Stale Content & Retrieval: The CAN gateway server will request a new version from the origin server when the following conditions are met:

    • Stale Content & Revalidation: The CAN gateway server will revalidateRefers to the process that occurs when a request for stale content requires that our edge servers check for a new version of the requested content on the origin server. with the origin server when the following conditions are met:

      Revalidation Result Description

      Match

      The following actions will take place when the cached version matches the version stored on the origin server:

      • The response headers for the asset cached on a CAN gateway server will be updated to reflect a new TTL.
      • The asset will be served to the requester via the edge server from step 1.

      Outdated

      If the cached version is older than the version stored on the customer origin server, then the following actions will take place:

      • The new version of the asset will be retrieved from the customer origin server.
      • The asset will be served to the requester via the edge server from step 1.

      Not Found

      If the requested content is not found on the origin server, then a 404 Not Found will be returned to the requester.

      Unknown

      If a CAN gateway server is unable to establish a connection with the origin server, then a stale version of the requested content may be served. Stale content may be served when both of the following conditions are true:

      • The Cache-Control:must-revalidate or Cache-Control:proxy-revalidate headers were not assigned to the cached version of the requested content.
      • The Cache-Control: max-stale header was assigned to the requested content and the max-stale time period has not expired.

      Learn more.

    • Not Cached: The CAN gateway server will forward the request to the origin server.
  3. The requested content is served to the HTTP client through the following path:

    Origin server CAN gateway server Edge server HTTP client

An edge server and the HTTP client will cache eligible requests. If the CAN gateway server requested the content from the origin server, then it will also cache the requested content.
Learn more.

More Information