admin管理员组

文章数量:1306001

Hi I'm using to test my wordpress site speed and I have an F for Leverage browser caching, it says:

The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:

.js

+Sans

+Sans:300,400,700

What else do I need to add to my .htaccess file? I already have this:

EXPIRES CACHING

ExpiresActive On

ExpiresByType image/jpg "access 1 week"

ExpiresByType image/jpeg "access 1 week"

ExpiresByType image/gif "access 1 year"

ExpiresByType image/png "access 1 week"

ExpiresByType text/css "access 2 month"

ExpiresByType application/pdf "access 2 year"

ExpiresByType text/x-javascript "access 2 month"

ExpiresByType application/x-shockwave-flash "access 2 month"

ExpiresByType image/x-icon "access 2 year"

ExpiresDefault "access 2 days"

ExpiresByType video/mp4 "access 2 year"

EXPIRES CACHING

Hi I'm using https://tools.pingdom. to test my wordpress site speed and I have an F for Leverage browser caching, it says:

The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:

https://ssl.google-analytics./ga.js

https://fonts.googleapis./css?family=Droid+Sans

https://fonts.googleapis./css?family=Lora

https://fonts.googleapis./css?family=Merriweather+Sans:300,400,700

What else do I need to add to my .htaccess file? I already have this:

EXPIRES CACHING

ExpiresActive On

ExpiresByType image/jpg "access 1 week"

ExpiresByType image/jpeg "access 1 week"

ExpiresByType image/gif "access 1 year"

ExpiresByType image/png "access 1 week"

ExpiresByType text/css "access 2 month"

ExpiresByType application/pdf "access 2 year"

ExpiresByType text/x-javascript "access 2 month"

ExpiresByType application/x-shockwave-flash "access 2 month"

ExpiresByType image/x-icon "access 2 year"

ExpiresDefault "access 2 days"

ExpiresByType video/mp4 "access 2 year"

EXPIRES CACHING

Share Improve this question asked Nov 1, 2016 at 18:56 Charles XavierCharles Xavier 1,0453 gold badges15 silver badges34 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

Only way to do this would be to download the stylesheets/fonts and add them to your server, since you can't affect Google's 1 day expiration headers.

Open your https://fonts.googleapis./css?family= links and get the individual fonts, for example: https://fonts.gstatic./s/droidsans/v6/s-BiyweUPV0v-yRb-cjciPk_vArhqVIZ0nv9q090hN8.woff2

Download that and save it to your server. Now you can use the same styles as in the google stylesheets but inside your own css file. Make sure to change the fonts.gstatic. link to the file on your server.

If you don't want to do that then a better way to handle your requests is like this:

<link rel="dns-prefetch" href="//fonts.googleapis.">
<link rel="dns-prefetch" href="//ssl.google-analytics.">
<link rel="stylesheet" href="//fonts.googleapis./css?family=Droid+Sans|Lora|Merriweather+Sans:300,400,700">
<script src="//ssl.google-analytics./ga.js" async></script>

EDIT 12/2: The reason you wouldn't want to do this is because Google may update the font, however, fonts don't really get updated that often.

本文标签: javascriptThe following cacheable resources have a short freshness lifetimeGoogle fontsStack Overflow