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 cached in the 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 cached 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 cached including the dynamic content.

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

    • The edge servers cache all content with status code HTTP 2xx 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 the cache still exists.

  • 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 CDN, you can set cache response headers to X-CDN-Cache-Status indicating whether a resource is cached or not. The supported values are as follows:

  • HIT: The resource was delivered from the CDN cache.

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

  • STALE: The resource was served from the cache 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 the cache is disabled due to the policy or configuration.

You can also ensure not to cache specific requests 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 has to 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

Revision created

commented latest release