Exclude Google Fonts from Cloudflare caching

I have hosted all my Google Fonts I want to use locally using the OMGF plugin.
I want to exclude them from Cloudflare caching as they are adding a lot of load time to my website.
How do I do that?

You can create page rules for each font file extension to avoid caching them:

URL pattern: /*.abc (where abc is your font file extention)
Setting: Cache Level: Bypass

Make sure you purge all your CF cache after creating the page rules.

Or you can set a header with a value that tells Cloudflare not to cache them. You do this at your origin server, or with a WordPress plugin.

1 Like

Thanks a lot floripare for the reply.

I am non tech Wordpress newbie and am on a free Cloudflare Plan. I have no Page Rules left.

You mentioned setting a header with a value to tell clodflare not to cache my fonts.
How do I do that?

All the google fonts have some kind of in this format "(https://fonts.gstatic.com/s///*.woff2).
I have more than 5 fonts and styles.

I have a “Insert Headers and Footers” Wordpress plugin installed.

What code do I insert? Can you give me the code format and tell me how to modify it accordingly?

Please dumb it down for a layman like me with steps if possible.

Thanks again. :grinning:

Hi,

The font URL you mentioned (starting with fonts.gstatic.com) point to Google’s servers, not yours. Are you sure you managed to properly serve the fonts out of your server? If you check OMGF’s documentation, you’ll see that not all Google Fonts are served from your server with their free plugin, it depends on how fonts are inserted on the page.

Cloudflare does not cache fonts that are served by Google or any other third-party provider, only fonts coming out of your own server, in which case their URLs would have to start with https://example.com/..., where example.com is your domain name.

What’s your domain?

My website is www.gutdecoded.com.
Please tell me what to do to just provide the fonts from my locally hosted ones and nowhere else and reduce the load time.

Thanks again.

This is a question you should ask your font plugin’s support forum. Your site is currently loading dozens of different fonts, many from your own site, many from Google’s.

Any font coming from your domain will be cached by Cloudflare by default unless you instruct it not to cache your fonts, in which case your loading time in all likelihood will be greater, not smaller, than what you are seeing currently.

To prevent Cloudflare from caching your fonts, you can try adding an HTTP header to your font files (the plugin you mentioned in the previous reply does not do that, it handles another kind of “header”). You should ask for more information on sites like stackoverflow.com or equivalent, but be prepared to handle technical instructions. Or else hire a developer (or ask a friend) to do this for you.

All Cloudflare resources to help you with that (that I am aware of) would involve paying. You can pay to have extra page rules, or move to a paid plan, which also includes more page rules.

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