I'm running a rails app on heroku and recently switched to cloudflare for CDN for asset serving. My understanding was that once I use cloudflare, my assets (ie js,css,images) would be served from cloudflare and not from my own server but in my heroku logs I still see the requests for assets. Do I need to configure something in my rails app like setting the asset_host or something? Thanks.
Cloudflare does not cache the resource when: The Cache-Control header is set to private , no-store , no-cache , or max-age=0 .
When an image is fetched from your origin, our systems automatically optimize it in Cloudflare's cache. Subsequent requests for the same image will get the smaller, faster, optimized version of the image, improving the speed of your website.
This is not the correct way to check if Cloudflare is caching your content. Head over to https://gtmetrix.com/, enter your site URL and navigate to the “Waterfall” tab. Click on any resource you wish to check and you should see something like this. Look at the “cf-cache-status” header to see the status.
It might be helpful to clarify what CloudFlare caches by default as well (just to make sure you know that not every file extension is automatically cached).
Note: Caching also depends on how many requests we get for the resources before it gets cached (minimum of three).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With