Caching

Caching in CDN refers to storing copies of web content at multiple edge servers across various geographical locations. It allows users to access content from a server that is geographically closer to them, improving the speed and efficiency of content delivery.

Features

  • Static Content Caching: Static content like HTML, CSS, JavaScript files, images, and videos are stored at CDN edge servers. Caching is based on the request method GET or HEAD and the HTTP response code defined in the cache policy. There will be no differences between static content and dynamic content. Content that should not be placed in cache must have defined cache control headers.

  • Dynamic Content Caching: With cache-control headers, you can customize the cache behavior to your needs and on enabling Caching on a CDN route, everything that matches the cache policy will be placed in cache, including the dynamic content.

  • Cache Policy: The default cache policy for IONOS Cloud CDN is as follows:

    • The edge servers store all content with status code HTTP 200 from the origin server for 24 hours if no cache control headers are given. Cache-control headers take precedence otherwise.

    • Content with HTTP 301, 302, or 404 will be cached for 10 minutes if no cache-control headers are set.

    • Stale content will be provided if the origin is unreachable and cached content is still available.

  • Automatic Purging: The CDN can automatically remove cached content based on a defined policy, ensuring that users always receive the most up-to-date version of the content when necessary.

Cache response headers

With IONOS Cloud CDN, you can set cache response headers to X-CDN-Cache-Status indicating whether a resource is stored at an edge server or not. The supported values are as follows:

  • HIT: The resource was delivered from the CDN's cached storage.

  • MISS: The resource was not found in cached storage; it was served from the origin web server and stored at the edge server. Further requests may be stored at the edge server if the cache policy matches.

  • STALE: The resource was served from cached storage but could have expired. Stale content will be delivered if the CDN is updating the content. A timeout or error from the origin server is provided.

  • BYPASS: All responses where caching is disabled due to the policy or configuration.

You can also ensure not to store specific requests at the edge server if the following requirements are met:

  • An X-Accel-Expires response header field was sent with a value of 0.

  • An “Expires” response header was sent with a date that is already expired.

  • The “Cache-Control” header has values like no-cache, no-store or private in the response.

  • The response header includes the Set-Cookie field.

  • If the response header includes the Vary field with the special value *.

Benefits

  • Reduced Latency: CDNs serve content from the nearest edge server, minimizing the distance data must travel, reducing latency, and improving load times.

  • Enhanced Availability: Cached content can still be served to the users even if the origin server experiences downtime, improving the availability of web services.

  • Content Relevance: With well-defined caching policies, you can ensure users receive up-to-date content even while serving content from the cached server instead of the origin server.

  • Scalability: Caching allows websites to handle higher data traffic without degradation in the content served to the user requests, making it easier to scale during traffic spikes.

  • Improved Security: By reducing the number of direct content requests to the origin server, caching helps mitigate certain vulnerabilities and provides an additional security layer.

Last updated

Was this helpful?