API: CDN cache
Cache level, cache times per file type, development mode, purging and pull zones.
/domains/{domain}/services/cdn cdn.cache Cache level
off, standard (static files) or aggressive (pages too, within the plan).
| Body field | Values | Meaning |
|---|---|---|
actionRequired | save | save, to change the cache level. |
valueRequired | off | standard | aggressive | off, standard or aggressive. |
curl -X POST -H "Authorization: Bearer $KEY" \
https://my.cloud9.ir/api/customer/v1/domains/example.com/services/cdn /domains/{domain}/services/cdn cdn.cache Development mode
Turns the cache off for a while so changes show at once.
| Body field | Values | Meaning |
|---|---|---|
actionRequired | dev_on | dev_off | dev_on or dev_off. |
curl -X POST -H "Authorization: Bearer $KEY" \
https://my.cloud9.ir/api/customer/v1/domains/example.com/services/cdn /domains/{domain}/services/cdn cdn.cache Cache times per file type
For each group (images, assets, fonts, media, files): on or off, the time kept on the nodes and the time in the visitor's browser, in seconds.
| Body field | Values | Meaning |
|---|---|---|
actionRequired | times | times, to change the cache times. |
r_<group>_on | 1 | 0 | Turn caching on for the group (images, assets, fonts, media or files). |
r_<group>_edge | 60 | 900 | 1800 | 3600 | 7200 | 21600 | 43200 | 86400 | 604800 | 2592000 | 31536000 | Seconds the nodes keep the group. |
r_<group>_browser | 0 | 1800 | 3600 | 14400 | 86400 | 604800 | 2592000 | Seconds the visitor's browser keeps the group. |
curl -X POST -H "Authorization: Bearer $KEY" \
https://my.cloud9.ir/api/customer/v1/domains/example.com/services/cdn /domains/{domain}/services/cdn cdn.cache Always online
The nodes keep the last copy of each page that visitors without a sign-in see, and show it while your server does not answer, instead of an error page. Signed-in visitors and forms always reach your server.
| Body field | Values | Meaning |
|---|---|---|
actionRequired | always_online | always_online. |
valueRequired | 1 | 0 | 1 on, 0 off. |
curl -X POST -H "Authorization: Bearer $KEY" \
https://my.cloud9.ir/api/customer/v1/domains/example.com/services/cdn /domains/{domain}/services/cdn cdn.cache Add a cache rule
Up to 25 rules per domain: for a path (prefix or exact), always cache for a time you choose or never cache; follow or override the site's headers; skip the cache when a cookie is set.
| Body field | Values | Meaning |
|---|---|---|
actionRequired | path_add | path_add. |
pathRequired | Text | The path, starting with /. |
match | prefix | exact | prefix: the path and everything under it; exact: only this path. |
rule_action | cache | bypass | cache: keep it for the chosen time; bypass: never cache. |
edge | Text | Seconds on the nodes, from the cache times list (not below the plan's shortest time). |
browser | Text | Seconds in the visitor's browser, from the browser times list. |
rule_origin | respect | override | respect or override the site's own cache headers for this path. |
cookie | Text | Skip the cache when the visitor has this cookie (for example a signed-in cookie). |
curl -X POST -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d '{"action":"path_add","path":"/blog/","match":"prefix","rule_action":"cache","edge":"3600","browser":"0","cookie":"wordpress_logged_in"}' \
https://my.cloud9.ir/api/customer/v1/domains/example.com/services/cdn /domains/{domain}/services/cdn cdn.cache Delete a cache rule
Removes a rule by its id, as GET services lists it in cdn.paths.
| Body field | Values | Meaning |
|---|---|---|
actionRequired | path_del | path_del. |
idRequired | Text | The rule id (8 hex characters) from GET services. |
curl -X POST -H "Authorization: Bearer $KEY" \
https://my.cloud9.ir/api/customer/v1/domains/example.com/services/cdn /domains/{domain}/services/cdn cdn.cache Origin shield
One node in Iran and one abroad fetch from your server; the other nodes take files from them, so your server sees far fewer requests.
| Body field | Values | Meaning |
|---|---|---|
actionRequired | shield | shield. |
valueRequired | 1 | 0 | 1 on, 0 off. |
curl -X POST -H "Authorization: Bearer $KEY" \
https://my.cloud9.ir/api/customer/v1/domains/example.com/services/cdn /domains/{domain}/services/cdn cdn.cache Follow or override cache headers
respect follows the Cache-Control your site sends on static files; override keeps files for the chosen times anyway.
| Body field | Values | Meaning |
|---|---|---|
actionRequired | origin | origin. |
valueRequired | respect | override | respect or override. |
curl -X POST -H "Authorization: Bearer $KEY" \
https://my.cloud9.ir/api/customer/v1/domains/example.com/services/cdn /domains/{domain}/cache/purge cdn.purge Purge the cache
Without a body the whole cache of the domain is purged. With urls (at most 30) only those addresses; an address ending in * purges everything under that path.
| Body field | Values | Meaning |
|---|---|---|
urls | Text | Full addresses, as an array or one per line; at most 30. Omit to purge everything. |
curl -X POST -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d '{"urls":["https://www.example.com/app.css","https://www.example.com/courses/*"]}' \
https://my.cloud9.ir/api/customer/v1/domains/example.com/cache/purge /domains/{domain}/pull-zones cdn.pull Create a pull zone
Creates <label>.<domain> served through the nodes from an origin host in one of your domains, and answers 201.
| Body field | Values | Meaning |
|---|---|---|
labelRequired | Text | One label, such as cdn-blog. |
originRequired | Text | A host in one of your own domains that holds the files. |
curl -X POST -H "Authorization: Bearer $KEY" \
https://my.cloud9.ir/api/customer/v1/domains/example.com/pull-zones No answer here? Sign in to the portal and open a ticket. Open a ticket