Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get my rails assets to be served by cloudflare instead of my server?

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.

like image 409
Harry Jiang Avatar asked May 08 '15 18:05

Harry Jiang


People also ask

Why is Cloudflare not caching?

Cloudflare does not cache the resource when: The Cache-Control header is set to private , no-store , no-cache , or max-age=0 .

Does Cloudflare automatically cache images?

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.

Is Cloudflare caching my site?

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.


1 Answers

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).

like image 142
damoncloudflare Avatar answered Sep 17 '22 18:09

damoncloudflare