Cache to change domain and path

Let’s say I have some content that I want to cache at
image-hosting.com/some/really/long/path/image.jpg.
I know that I can add a DNS entry so that it is on my domain. So I would also be able to find the image at
cutsom-domain.com/some/really/long/path/image.jpg.

Is it also possible to change the path so that it could be at
custom-domain.com/images/image.jpg?

I am new to cloudflare, so apologies if this seems obvious.

Cloudflare will only cache content for domains in your Cloudflare account. So if I have a domain: example.com, but want to use myimages.com, the myimages domain also has to be in my Cloudflare account.

Cloudflare is fairly transparent, in that images normally served from your website continue to use the same URL, but get cached in transit. It’s not a typical CDN where you push your images off to some other (sub)domain.

1 Like

Ah, okay that was the piece of information that I was missing. I’m trying to host my assets from github, so I cannot set up cacheing on raw.githubusercontent.com

Does that mean that I can create a worker to do this for me?
For example:

  • A worker registed on route: custom-domain.com/images/*
  • That fetches from image-hosting.com/some/really/long/path/$1

Then the result from my worker can be cached as it is on my domain?

Yes, there’s a Workers recipe for pulling content from an external source.