Using Page Rules to improve TTFB

To improve my time to first byte speed - I am using the following page rule…

example.com/*
Forwarding URL - 301 Permanent redirect
www.example.com/$1

So I am forcing “www” before it even hits my server and needed htaccess redirects.

BUT - I need to skip this rule if google wants to access my sitemap.xml or ads.txt directly at the https://NO WWW – Then I need it to default back to Cloudflare caching default without redirect.

How do I cancel out that page rule for ANY xml file or txt file anywhere on the site — but still server them through the standard Cloudflare caching?

Thanks for the help

create a rule just before your existing rules with example.com/ads.txt

Would this work:

https://example.com/*.xml
Cache Level: Standard

And this would make sure the 301 redirect page rules are ignored?

Would /*.xml

Catch a sitemap in sub-folders??

Thanks again

https://example.com/sitemap.xml before 301 redirect would definately work.

I have multiple sitemaps in multiple directories - I could really do with a wildcard way of allowing all xml and txt files on the site to not be 301 redirected.

I think it could be:

> *.example.com/*.xml
> and
> *.example.com/*.txt

This page might help you.

https://support.cloudflare.com/hc/en-us/articles/218411427-Understanding-and-Configuring-Cloudflare-Page-Rules-Page-Rules-Tutorial-

Google treats www and naked domain, as well as their HTTP and HTTPS versions, as different websites. If Google is allowed to crawl the sitemap.xml in the naked domain, that will not help with indexing the www version of it. Not sure about ads.txt, but I’d assume the same mindset prevails.

If you want to improve TTFB, you need a page rule that Caches Everything (including html, bypassing your server). You can then realize TTFB under 20ms.
Like @cbrandt pointed out, you should only use one version of your site. Either with, or without, www.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.