Cloudflare Cache Tags

I was hoping to be able to use Cache Tags which I have setup in our Cloudflare account in front of my render app, however, the response headers aren’t visible when I check. Is this a known issue?

I’m expecting a lot of heavy traffic from Thursday, and wanted to have extra caching in place. Without this, it seems like my app is going to get the full brunt of traffic. Any suggestions or alternatives appreciated.

Hi David,

Thanks for reaching out.

We don’t currently cache anything for Web Services, however you should be able to configure your own Cloudflare “in front” of Render’s and setting headers should come through.

If you could share some further details of the issue you are experiencing it may help us troubleshoot it with you, e.g. any logs/errors/output, headers, specific domains/URLs, service ID(s), reproduction steps, etc.

If you don’t want to share these details on the community forum, please feel free to raise a ticket with support@render.com.

Kind regards

Alan

Thanks, Alan. I guess the issue I have is that with my Rails app, when I set:

response.headers['Cache-Tag'] = 'abcdefg'

And then curl the webservice, I don’t see Cache-Tag visible in the list of headers. If I change this to X-Cache-Tag it does appear. And I think this might just be that the CF that sits in front of render.com, even though it is not caching, it seems to still be removing the header.

Hey David,

Your intuition is correct. All traffic goes through Render’s Cloudflare zone, so the header will be stripped regardless of whether caching is enabled. You can achieve the same functionality using the Cache API with a Cloudflare worker.

You can set the X-Cache-Tag response header in your Render service. In the worker, you can then set Cache-Tag to the value of X-Cache-Tag immediately after (or in place of) response.headers.append('Cache-Control', 's-maxage=10'); so that it is present when you call event.waitUntil(cache.put(cacheKey, response.clone()));.

This should achieve the same functionality that you would expect by setting Cache-Tag.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.