Google font not caching with WordPress APO

Hello and thanks in advance for any help. I am trying to figure out how to cache google fonts with the WordPress APO. Many docs and blog posts suggest that it basically works automatically, but something is preventing that from working on my site. My HTML and images are showing a cache HIT, but the fonts still appear to be loading from fonts.gstatic.com. I don’t see the request url changing or a cf-apo-via:proxy value on the css link or font file requests. Viewing the page source also shows “”

This documentation (https://developers.cloudflare.com/automatic-platform-optimization/troubleshooting/faq/#are-google-fonts-optimized-when-apo-is-activated) says " For example, the URL will change from https://fonts.gstatic.com/s/... to https://example.com/fonts.gstatic.com/s/... when the site loads. For proxied fonts, the cf-apo-via:proxy header is returned."

Does anyone have tips on how to get this enable. Could dns, page rules or other settings interfere with google font caching when the other apo features seem to work?

That’s why as they are being served from a 3rd-party domain.

Download the fonts from Google Fonts, then host the fonts on your origin host/server and serve them from the domain name.
In that case they will be cached as far as WOFF/WOFF2 file type is cached “by default” as following on the list from link below:

If so, consider using CORS attribute as they might be blocked.

2 Likes

Thanks for the response. I am aware that I could host the fonts locally or even use a worker to cache them. However, I am more interested in using the features provided by the Wordpress APO that can cache google fonts at the edge. I am hoping to not re-engineer their solution that will ultimately perform worse. Have you figured out how to cache the fonts with the APO per the link I shared in the original post?

I am going to bump this thread one more time. I am hoping to find the solution to this and have it here to share with others. Thanks.