How to cache asset stored on Google Cloud Storage?


How can I cache assets stored on google cloud storage (GCS)? I’ve been trying to make it work in the past 2 days with no luck. My website have backend & frontend, and the assets is stored on GCS. I tried the following guide:

Here’s what I did:

  1. I created a bucket on GCS ‘
  2. On Cloudflare I set CNAME with the following:
    Name: img
  3. I set all object in GCS bucket ‘readable by public’

The Image is still not served via Cloudflare and there’s no CF status on the header of the assets. Am I missing something? I would really appreciate any input.

Thank you.

Have you set :orange: in your DNS settings?

Yes, I have turned it on. Cloudflare is caching the content served from my servers, but not from GCS.

What IP address does the host resolve to?

Assets still being served from (Google)

Can you post your domain and a screenshot of the DNS entry in question (redact any sensible information, such as your own IP addresses).

Sure, here’s the screenshot.

You should say also the domain, it’s useless otherwise.

Sorry, I can’t share the domain because it’s for internal use.

Then there is nothing we can do, without seeing what it’s happening… Can you at least share the headers of a request?

Your site requires a login to even access the page on the main site and on the subdomain displays no images…

Perhaps you need to refresh your DNS. The record is orange clouded so it resolves to a Cloudflare IP.

1 Like

It should resolve to Cloudflare because it is orange or it does resolve to Cloudflare because “it does” (you checked)?

If it does it most likely is a caching issue as @user7121 wrote it still resolves to Google’s address.

@user7121, are you sure that would work in the first place? The request to Google does not require in the host header?

In theory it should work, they allow it: Host a static website  |  Cloud Storage  |  Google Cloud

They even tell you to use a third-party CDN for HTTPS.

Fair enough, thanks. So it should work and the question is why would he get the actual IP address when the system is properly configured (as @cs-cf hinted). Maybe really caching, I’d wait a bit more.

Could it also be that for some reason there is a no-cache on the bucket?

It’s caching for 3600s

You can check the domain:

The image is still served through GCS instead of Cloudflare.

DNS screenshot:

Header screenshot:

That host does resolve to Cloudflare. Check out

The problem in your case is, you probably link somewhere without a proper protocol scheme, which turns your link into a relative one with the host appended to the original Google link. Have a thorough look at the link you are requesting.

I thought I should see “CF-Status” on the header everytime it goes through Cloudflare network? Could you please elaborate which link are you referring to? If you’re referring to the asset link, I just make the object viewable on GCS and it automatically provide me with the link.

The request you posted goes to a Google server. What were you trying to show with it?