TTFB + Cache everything + .haccess

Hello,

Cloudflare gives very long TTFB - about 1 sec. (my server’s origin is 100ms) without enabled “Cache everything” (with enabled - ~100ms). But if i enabling “Cache everything” on my static website - i can not get to work my .htaccess rules. There i have rule to 302 redirect users using mobile devices to mobile version of site.
So with “Cache everything” enabled this redirect works only few times after cache purge - after that it redirects all time to desktop or mobile version - randomly.

  1. Is any way to improve Cloudflare’s TTFB without enabling “Cache everything” ?
  2. Is any way to not cache my .htaccess with “Cache everything” enabled ?

Thanks.

This is because Cloudflare CDN Cache does not support HTTP Vary header Cloudflare CDN Cache To Support HTTP Vary Header so when Cache Everything is used, CF CDN Cache will not vary cache response based on device/user agent. Best solution is to do away with a separate mobile version of your site and move site to a full responsive design so that CF CDN cache will work for both desktop and mobile.

1 Like

I just figured out the problem.
Found that Cloudflare has mobile redirect option by itself.
So made a mobile site on subdomain, enabled mobile redirect on CF to that subdomain.
Enabled “Cache everything” on both root domain and subdomain.
Removed redirect rules from .htaccess.
Now i have normal TTFB and mobile traffic redirection working.

1 Like

Nice work!

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