I tested my site via Pingdom and got this:
I searched but couldn't find a solution to this. Does anyone know how I can get this 14 to 100?
I tested my site via Pingdom and got this:
I searched but couldn't find a solution to this. Does anyone know how I can get this 14 to 100?
Not a complete solution, but you can improve the situation by combining the two requests to one:
I do that for two fonts on one of my sites and score 86 versus your 14. Importantly, this is a genuine speedup, not just a hack to reduce an arbitrary score.
Since you cannot control Googles headers (including expiration headers), I can see only one solution – download these two stylesheets and fonts to your own hosting server, change HTML tags accordingly.
Then, you can set expiration headers (what Pingdom called 'lifetime') as you wish.
For example, open the first link:
Download this .woff2 file and save it anywhere on your webserver. Copy & paste this piece of stylesheet into any of your own CSS files or HTML. Change the link from fonts.gstatic.com to your new URL.
Google serves these fonts with expiration time of 1 day. You could easily set it to 30 days now.
What I got to work was adding PHP as a post-processor to my CSS files in my .htaccess file with the code (I'm using a custom .pcss file extension - just to make it separate from my simple CSS files):
Then I used the following code in my CSS file to get and echo the content of the font URL I wanted.
First of all it's important to clarify the distinction between caching the Google Fonts CSS files and the actual font files. According to the Google Fonts FAQs, their font files are actually cached for a year. It's the CSS files that are cached for 24 hours:
I would recommend against hosting these CSS files yourself, as you will fall behind and not be using the latest versions of the fonts as they're updated.
However, there are a couple ways you can speed up the CSS request:
https://fonts.googleapis.com/css?family=Montserrat|Open+Sans
<link href="https://fonts.googleapis.com/css?family=Montserrat|Open+Sans:400,400i,700" rel="stylesheet">
A fairly easy workaround would be to generate your own kit with Font Squirrel's Webfont Generator:
https://www.fontsquirrel.com/tools/webfont-generator
To be able to use this, you would need to download the fonts (Montserrat and Open Sans are both available on Font Squirrel) and add them to the generator. This can be used for adding further customization. (I've used it many times in cases where the font in Google Webfonts didn't have the necessary subsetting for Hungarian language even though it was available in the original font.)
Be aware that you are not allowed to cache the css provided by Google more than 24 hours.
Just saying... according to Google's terms and conditions.