Hi everyone,
I am trying to set up a Content Delivery Network (CDN) on DigitalOcean to improve the performance and global delivery speed of my website, but I’m not entirely sure about the correct configuration steps.
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!
Hey Prakash! 👋
If you’re using DigitalOcean Spaces, setting up a CDN is super easy:
Head over to the Spaces dashboard and create a new Space (basically a storage bucket).
While creating it, check the “Enable CDN” option, this gives you a CDN endpoint like https://your-space-name.nyc3.cdn.digitaloceanspaces.com
.
Upload your static files (images, CSS, JS, etc.) to that Space.
Use the CDN URL in your website to load those assets faster from edge locations around the world.
Point a custom domain (like cdn.yoursite.com
) to that CDN endpoint using a CNAME record, then enable SSL.
Docs here if you want to dig in:
https://docs.digitalocean.com/products/spaces/how-to/enable-cdn/
If you’re self-hosting on a Droplet, you can also put Cloudflare in front of it for full-site CDN and DDoS protection.
- Bobby
Heya,
bsolutely—let’s walk step by step through setting up a CDN on DigitalOcean to accelerate your website’s content delivery.
DigitalOcean’s Spaces product has built-in CDN support via their integration with the DigitalOcean CDN (backed by Fastly).
I’ll guide you through configuring a CDN for your Spaces bucket, which is the most common approach (though you can also put a CDN in front of your Droplets if needed).
If you haven’t already:
Log in to your DigitalOcean Control Panel.
In the left menu, click Spaces.
Click Create a Space.
Choose:
Datacenter region nearest to most of your visitors.
Enable CDN option (or you can enable it afterward).
Set permissions (public or private).
Click Create a Space.
✅ Tip: For CDN delivery, files typically need to be public.
If you didn’t enable CDN at creation time:
Go to your Space in the DigitalOcean dashboard.
Click the Settings tab.
Find the CDN section.
Click Enable CDN.
Optionally, add a custom subdomain (e.g., cdn.yourdomain.com
) by:
Entering the subdomain.
Verifying ownership (you’ll get a CNAME record to set in your DNS).
After propagation, DigitalOcean provides an SSL certificate automatically.
When enabled, you’ll see a CDN endpoint URL (e.g., https://your-space.nyc3.cdn.digitaloceanspaces.com
).
Use the Spaces web console, s3cmd
, rclone
, or the AWS S3-compatible API to upload images, videos, CSS, JS, etc.
Make sure objects are public for the CDN to serve them.
Update your website so static assets point to the CDN endpoint or your custom subdomain. For example:
<img src="https://cdn.yourdomain.com/images/logo.png" />
or
<link rel="stylesheet" href="https://your-space.nyc3.cdn.digitaloceanspaces.com/css/styles.css" />
You can fine-tune cache behavior:
Use Cache-Control
headers on your files (e.g., max-age=31536000
for one year).
You can set default cache settings in the Settings > CDN tab.
If you prefer to put a CDN in front of your Droplet (origin server) rather than Spaces:
Use Cloudflare, Fastly, or DigitalOcean Load Balancers with Cloudflare.
You configure your DNS to point to the CDN provider, which fetches content from your Droplet.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.