利用浏览器缓存(内部)

时间:2013-11-29 11:11:49

标签: apache caching pagespeed

我使用PageSpeed Insights获得以下内容:

Leverage browser caching

但在我的Apache站点配置中,我有:

    <IfModule mod_expires.c>

             ExpiresActive On
             ExpiresDefault "access plus 1 seconds"
             ExpiresByType text/html "access plus 1 seconds"
             ExpiresByType text/css "access plus 2 weeks"
             ExpiresByType text/javascript "access plus 2 weeks"
             ExpiresByType application/x-javascript "access plus 2 weeks"
             ExpiresByType image/* "access plus 2 weeks"

    </IfModule>

mod_expires已启用。 似乎工作,因为其他css,jpg,png,...文件被缓存。但是有些js和css文件不是。我做错了什么?

您可以尝试http://itransformer.es

1 个答案:

答案 0 :(得分:4)

我相信apache使用 application / javascript代表js文件

ExpiresByType application/javascript "access plus 2 weeks"

如果你签入apaches mime.types text / javascript被注释掉了。

我还建议您考虑优化网站图片

http://itransformer.es/public/img/carrete.png is resized in HTML or CSS from 2135x1555 to 300x219. Serving a scaled image could save 561.5KiB (98% reduction).
http://itransformer.es/public/img/logo.png is resized in HTML or CSS from 608x99 to 500x81. Serving a scaled image could save 29.3KiB (33% reduction).
http://itransformer.es/public/img/carrete2.png is resized in HTML or CSS from 2000x298 to 1903x284. Serving a scaled image could save 3.7KiB (10% reduction).
http://itransformer.es/public/img/gplus.png is resized in HTML or CSS from 62x64 to 35x36. Serving a scaled image could save 1.9KiB (68% reduction).
http://itransformer.es/public/img/tw.png is resized in HTML or CSS from 62x64 to 35x36. Serving a scaled image could save 1.5KiB (68% reduction).
http://itransformer.es/public/img/fb.png is resized in HTML or CSS from 62x64 to 35x36. Serving a scaled image could save 1.0KiB (68% reduction).

它们是在目标网页上加载的一些大图像,并且真正减慢了第一次访问加载时间。确保当您查看页面时加载您关闭自己的浏览器缓存以模拟第一次进入的人。

祝你好运 Narimm