Typo3 8.5 - 启用客户端缓存

时间:2017-09-25 14:08:17

标签: html caching typo3 browser-cache client-side

我正在尝试在由Typo3 8.5.3支持的网站上启用客户端缓存。

我找到了这个页面: https://typo3.org/documentation/article/using-cache-control-headers-in-typo3/

但我无法让它发挥作用。

这些是我的设置,我错过了什么?

config {
   no_cache = 0
   sendCacheHeaders = 1
   cache_period = 86400
   cache_clearAtMidnight = 1
}

我已将此包含在我网站上的模板使用中,但似乎无效。我不知道这是服务器配置还是只有Typo3配置。

我想启用客户端缓存以满足谷歌关于他的“速度测试”的建议:https://developers.google.com/speed/pagespeed/insights/

这是我在js文件中获得的当前标头:

Date    Mon, 25 Sep 2017 14:01:18 GMT
Server    Apache
Last-Modified     Mon, 17 Jul 2017 07:13:51 GMT
ETag         "224cf4-20976e-5547e24169863"
Accept-Ranges       bytes
Content-Length      2135918
Content-Security-Policy     default-src * ; style-src * 'u…'unsafe-inline' 'unsafe-eval'
X-WebKit-CSP       default-src *; style-src * 'un…'unsafe-inline' 'unsafe-eval'
Content-Type      text/javascript
Strict-Transport-Security       max-age=31536000
X-XSS-Protection       1; mode=block
X-Content-Type-Options      nosniff

1 个答案:

答案 0 :(得分:0)

您可以通过将以下配置添加到.htaccess来控制到期日期(您可能必须添加/删除一些配置以符合您的确切条件,但模式应该清晰):

ExpiresActive On
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week"
ExpiresByType image/png "access plus 1 week"
ExpiresByType image/svg+xml "access plus 1 week"
ExpiresByType text/css "access plus 1 week"

这会将给定文件mimetypes的到期时间设置为1周。如上所述,您可能需要调整哪些文件mimetypes被控制以摆脱所有警告。