I can't get cache-control: max-age to be anything other than zero for my static files

Using Django for my app and Whitenoise and have set up everything as per Render’s instructions. Site is working well but all of my static files have max-age=0 for the cache-control header. Not sure how to troubleshoot this further and am looking for suggestions.

Here is the output from curl for getting an image file:

HTTP/2 200
date: Sat, 21 Sep 2024 00:16:17 GMT
content-type: image/webp
content-length: 57144
cf-ray: 8c65dd9dcdbecf4e-CMH
cf-cache-status: DYNAMIC
access-control-allow-origin: *
cache-control: max-age=0, public
etag: “66ee02a8-df38”
last-modified: Fri, 20 Sep 2024 23:18:00 GMT
cross-origin-opener-policy: same-origin
referrer-policy: same-origin
rndr-id: f5719fc7-e841-4686
x-content-type-options: nosniff
x-render-origin-server: uvicorn
server: cloudflare

Assuming this has something to do with CF but even if so, how do I solve it? I have not yet pointed my real domain to my .onrender.com sub-domain, if that matters.

Hi,

This is a side-effect of Render Web Services being fronted by Cloudflare, which is configured not to cache.

Using a CDN for static assets is a feature request on our feedback site, but I don’t have an ETA: https://feedback.render.com/features/p/cdn-for-static-assets-in-backend-apps

A workaround could be to provision your own Cloudflare account with a custom domain to override caching options. This has come up in other topics in the community, e.g.:

Thanks, I am in the process of setting up CF. Having some caching issues there but started a new topic. They may not be Render related.