Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am experimenting with Cloudflare, mainly to relief the load of my webserver in peak moments. I just signed up and it seems to be working (all my traffic is being proxied) but Cloudflare does not seem to be caching anything.

My webserver is explictly sending Cache-Control headers that vary between 1 minute (i.e. Cache-Control: max-age=60, public) and 7 days. I was hoping that this way, my webserver would never be serving the exact same page twice within a minute. However, if I look at the apache logs of the web server, every request is directly proxied to the webserver, even when I request exactly the same resource several times in a minute.

Is this the expected behavior? How do I make CF serve cached versions of my website?

share|improve this question
    
Are you trying to get CloudFlare to cache HTML files? they have a list of file types they do cache here cloudflare.tenderapp.com/kb/top-frequently-asked-questions/… but they don't cache HTML –  sam Jul 30 '11 at 12:24
    
No, it's mostly png and json data. However I am not sure how they determine the type. Do they analyze the content type header or expect some kind of file extension? –  Jeroen Jul 30 '11 at 13:46
    
@Jeron JSON won't be cached by CloudFlare whatever you set, however PNG images should be. I believe they 'dumb detect' based on file extension (Rather than parsing headers) but you might want to check with them. CloudFlare isn't really designed to be used as a CDN, although it provides that functionality it's rather limited compared to something like Amazon Cloudfront or Edgecast. Though looking at your cache headers you might also want to set Etags, Expires and Last-modified as CloudFlare may depend on those –  sam Jul 30 '11 at 14:25
    
You are right. I was assuming they would rely on content-type headers but apparently they use file extentions to determine what to cache. That is a major bummer, I'm hosting a REST api, and nothing has any file extentions. Guess I should look for another CDN... might open another topic for that though. –  Jeroen Jul 30 '11 at 18:42
    
@Jeron If you're looking for CDN's to test, I'd suggest ether Voxel Voxcast, Amazon Cloudfront or MaxCDN. All of them have a 'pay what you use' plan (I.E. transfer 1GB a month, pay for 1GB a month). Once you've got a better plan of what your usage is get in touch with Edgecast or Akamai as they offer cheaper plans but only on high volume transfers. CloudFlare is great for many things, but there are better solutions avaliable for CDN's –  sam Jul 30 '11 at 20:53
add comment

2 Answers

up vote 4 down vote accepted

I actually work for CloudFlare & thought I would jump in.

-Please keep in mind that caching will take a few days to build out & it depends on the number of requests for the static resources.

-Another thing to keep in mind that we would only proxy what you have set in your DNS settings (orange cloud on the subdomain). If you have an images or CDN subdomain, for example, you would want to make sure it is both added in CloudFlare & covered with an orange cloud.

share|improve this answer
add comment

What headers is CloudFlare sending as part of the request? It might just be trying to revalidate the content (if it's sending Cache-Control: max-age headers of it's own), and there might be some option to turn that off in their control panel.

If it's really making a completely new request every time, I'd say that you're almost certainly not setting the headers correctly (putting a , instead of a ;, or something trivial like that), and it's making CF upset. You'll be best off in that case to put up a packet dump (using tcpdump -s 0 to capture the entire conversation) of a few requests/responses between CF and your webserver, so we can examine the headers and tell you what you've missed.

share|improve this answer
    
CloudFlare seems to be simply passing on the Cache-Control parameter back to the client. The syntax seems to be OK; at least firefox is understandig it. –  Jeroen Jul 30 '11 at 13:55
    
That screenshot doesn't indicate that firefox "understands" it, merely that it sees it; also, Firefox might be parsing something more laxly than CF (which could take a more strict view of things). –  womble Jul 30 '11 at 13:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.