Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Accepted Answer
Clarifying @jarland’s answer a bit: The Spaces API itself does not have support for purging the CDN’s cache, but the DigitalOcean platform API does. The Spaces API was designed to emulate the AWS S3 API so that developers could use it as a drop-in replacement for S3 existing projects. Spaces-specific functionality like the builtin CDN are not part of the S3 API but are support in the DigitalOcean API.
First you’ll need to find the ID of you CDN endpoint. You can do that by listing your CDN endpoints using:
curl -X GET -H "Content-Type: application/json" \
-H "Authorization: Bearer $API_TOKEN" \
"https://api.digitalocean.com/v2/cdn/endpoints"
Then you can purge the cache with:
curl -X DELETE -H "Content-Type: application/json" \
-H "Authorization: Bearer $API_TOKEN" \
-d '{"files": ["*"]}' \
"https://api.digitalocean.com/v2/cdn/endpoints/<CDN_ENDPOINT_ID>/cache"
That command would purge the entire cache, but you could list specific files as well.
The DigitalOcean CLI, doctl, supports these as well:
To list the CDN endpoints run:
doctl compute cdn ls
And to purge the cache, run:
doctl compute cdn flush <CDN_ENDPOINT_ID> --files [*]
Find the full API reference docs here: https://developers.digitalocean.com/documentation/v2/#cdn-endpoints
Greetings!
Great question. To purge the cache you would need to go through the control panel, but this is probably not the ideal method for automation. Instead, you should focus on the TTL. This document will give you a bit more insight into that:
https://www.digitalocean.com/docs/spaces/how-to/manage-cdn-cache
You can set the TTL for the whole space or individual files (whole space being a bit easier). Once TTL is reached, the CDN should refresh it’s cache.
Jarland