为什么 Varnish Cache 不能缓存 .woff 文件?

Why can't Varnish Cache cache .woff files?

我有一个 .woff 文件,无论我的 VCL 配置如何,Varnish 都会对其进行一次命中。这种文件类型是否有什么东西阻止它被缓存?

我正在使用 Varnish 4.1.3、Ubuntu 14.04.2 LTS 和 Apache 2.4.7。

您必须让 Apache 发送正确的 Expires header 以便 Varnish 缓存这些字体文件。更改您的 Apache 配置/.htaccess:

  1. 为字体文件添加正确的 MIME 类型:

    AddType application/font-woff woff

  2. 指定您希望 Varnish 缓存的最长有效期:

    ExpiresByType application/font-woff "access plus 1 month"