Hey everyone, I’ve been trying to get my mind around the whole content delivery network thing. I am looking to optimize load times of my images in different regions.
My current setup is: A VPS located in Germany (hosting is hetzner), which hosts a nextjs app, and a directus cms, both proxied through cloudflare
The images are stored on my drive (that’s how directus does it), and are served through a url, that is proxied through cloudflare. The images are transformed using the cms api.
What I wanted to do was have these images be served from different locations, to improve the speed.
I was thinking of either having the images on Amazon S3 instead, and serving them with cloudfront. Another idea I had, was to enable cache reserve on cloudflare, or potentially having the images on cloudflare r2 (cloudflare images aren’t an option, no native way to integrate easily with my content management system).
So, my questions are:
Will enabling cache reserve, and having the images on r2 result in a similar setup to amazon s3+cloudfront?
Will enabling cache reserve, and NOT having the images (therefore keeping them on my server), make them served through the cdn (so, multiple locations).
will cache reserve improve the performance of my website? (NextJS, primarily server-side rendered website).
are there any other steps I could take to improve the performance of my website? (excluding optimizing on my frontend-code side, will do that anyway)
The advantage of using Cache Reserve is that it requires (almost) zero setup or changes to your infrastructure and workflow. You can just try it. If you are unhappy, disable it again.
Disadvantages are that you still need to have all the images on your drive and that you can’t control which files you want on Cache Reserve and which should only be cached at the Edge.
R2/S3 give you more control, but with more control comes more setup.
Neither Cache Reserve nor R2/S3 really have much to do with this. All of these still store the files in a single location. Their primary job is to reduce the load on your server / provide easily scalable storage.
Using them improves speed because your server has to do less work, but they will not serve the images from different locations on their own.
However, Cloudflare’s Edge already caches your files at all of their locations around the world by default. Cloudflare may require you to use a paid product like Images/R2/Cache Reserve if your site is serving a disproportionate amount of images.
Cache Reserve is already storing the images in R2. You would either use Cache Reserve if you want the automatic solution, or R2 if you want more control/not store the images on your server at all.
But yes, Cloudflare + R2 is similar to using S3 + Cloudfront.
Cache Reserve has nothing to do with multiple locations. Cloudflare always serves your assets from all locations, but effectiveness depends on the popularity of your site.
Yes, by reducing the load on your server.
Hundreds, maybe thousands…
Yes. And again, you can just try them and see for yourself. No setup required, so just try and disable it if you don’t like the results.