Site logo

Archived topic

Need to make TTF and WOFF2 load from my CDN

10 replies · Started by Tamhas on February 14, 2019

Viewing posts 1–11 of 11

Hi! I would like to make the TTF and WOFF load from my CDN instead of from my server:

/wp-content/plugins/gp-premium/general/icons/gp-premium.ttf
/wp-content/themes/generatepress/fonts/generatepress.woff2

They are on the CDN but page is not loading them from there for some reason.

How can make that happen please?

Hi there,

I believe that would depend on your CDN. It should happen automatically.

Have you been in touch with your CDN support yet?

The CDN has pulled the files, they are on it ok. But the site is still telling browser to pull from original site url instead of cdn url. I am using cdn enable for the url re-writing, everything else is working fine but for the two mentioned files. How could I manually re-write those, please?

I'm not sure, unfortunately. Are you using a plugin to set the CDN up on your site?

hi yes I am using KeyCDN’s “Cachd enabler”. It re-writes everything but not those two for some reason.

I know little about all this, but I was thinking since the files are in your theme, there must also bring a line or two of code in your theme tell the browser where to pull the files from. And that that could be changed manually. If I knew where is was. And I did have a look but no luck.

There isn't really anything special about how the theme adds those files - they're added using @font-face.

It might be worth checking with the plugin developer whether there's something we need to do manually in order to include them in the CDN.

OK, asking them, thanks. Meant to say "cdn enabler", not cache enabler BTW

Actually i had found font face before, and I thought maybe I could change the URLs for the fonts as below ... but that didn't work either. No idea, that's just my best guess. I am using System Stack fonts BTW.

@font-face {
font-family: 'GeneratePress';
src: url('fonts/generatepress.eot');
src: url('fonts/generatepress.eot#iefix') format('embedded-opentype'),
 url('https://cdn.mysite.com/wp-content/themes/generatepress/fonts/generatepress.woff2') format('woff2'),
url('https://cdn.mysite.com/wp-content/themes/generatepress/fonts/generatepress.woff') format('woff'),
url('https://cdn.mysite.com/wp-content/themes/generatepress/fonts/generatepress.ttf') format('truetype'),
url('fonts/generatepress.svg#GeneratePress') format('svg');
font-weight: normal;
font-style: normal;
}

Doesn't look like you changed all of the URLs.

However, I would assume the CDN plugin should re-write those requests without you needing to manually change the files.

No only changed the woff2 and ttf so far, as that's what I am seeing in gtmetrix. Just because that's what their test is pulling.

If it works I would change them all. Might it work if I did that right now?

Yes their plugin re-wrote everything else fine. Just not these too. Don't know why.

Hmm, I'm not sure. Maybe you have some sort of caching going on preventing the change from showing right away? Manually changing the link like that should work in theory.

This archived topic is closed to new replies.