Set up CDN¶
Note
The cache settings do not allow objects to be cached that have a No-Cache rule in the header, such as Cache-Control: (no-store|no-cache|private) or Cache-Control: max-age=0.
Before you can cache your website content with Myra, you must enable caching for your subdomains and define the objects and paths that should be cached by the CDN.
Proceed as follows to set up CDN for your subdomains:
-
► Set up the API, see Getting access to APIv2.
-
► Enable the CDN option for all required subdomains by changing the value of the attribute
cache_enabletotrue, see endpointPOST /domain/{domainId}/{vHostName}/settings.Note
If a change must be made to the settings of the subdomains, all possible attributes must be passed with the individual settings. Attributes that are not defined in the body are reset to the default value.
-
► Create a cache entry for each subdomain and for each object you want to cache, see endpoint
POST /domain/{domainId}/{vHostName}/cache-settings. -
► Check whether the defined objects have been cached.
You can determine whether an object is cached at Myra or not by checking the X-CDN header in the response header.
You can make the following decisions using the X-CDN header:
- X-CDN header missing: the resource was not delivered from Myra's cache.
- X-CDN: 1: the resource was delivered from Myra's cache
- X-CDN: 2: the resource was delivered as a stale object from Myra's cache.
You can check the response header using the developer tools in standard browsers or on the command line with
wgetorcurl. -
➔ The CDN for your subdomains is enabled and the defined objects are delivered by the Myra CDN.