0

我想在 IIS 8.5 上为 google 字体指定一个缓存验证器。

http://fonts.googleapis.com/css?family=Open+Sans:400,400italic,300,700,600

我在 web.config 上所做的如下;

<staticContent>
     <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="10.00:00:00" />
</staticContent>

我还通过扩展添加了缓存

<caching>
      <profiles>
           <add extension=".woff" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="23:59:00" />
           <add extension=".ttf" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="23:59:00" />
           <add extension=".gif" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="23:59:00" />
           <add extension=".js" policy="CacheForTimePeriod" kernelCachePolicy="CacheUntilChange" duration="23:59:00" />
           <add extension=".png" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="23:59:00" />
           <add extension=".jpg" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="23:59:00" />
           <add extension=".css" policy="CacheForTimePeriod" kernelCachePolicy="CacheUntilChange" duration="23:59:00" />
      </profiles>
</caching>

但我仍然无法为我使用的 Google 字体应用缓存验证器。我还尝试将静态内容的过期时间设置为例如 2030 年 5 月,但 Google PageSpeed 也没有认识到这一点。* 我已经设法用 .httaccess 做到了,并检查了 stackoverflow 上的 .htaccess 主题。*

4

1 回答 1

1

您只能对服务器提供的内容而不是外部内容应用缓存验证器;-)。此外,这是一个误报,因为 Google 字体具有缓存控制指令:

https://redbot.org/?uri=http%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DOpen%2BSans%3A400%2C800

于 2015-09-10T10:02:22.003 回答