好的,我仍在尝试了解一些缓存内容,并且已经浏览了一些可以在 Google 上找到的示例。我已将以下代码添加到我的 .htaccess 文件中:
### activate mod_expires
ExpiresActive On
### Expire .gif's 1 month from when they're accessed
ExpiresByType image/gif "access plus 3 months"
ExpiresByType image/png "access plus 3 months"
ExpiresByType image/jpg "access plus 3 months"
ExpiresByType text/javascript "access plus 3 months"
使用 Chrome 审计工具和 YSlow Firebug 工具,看起来这正在缓存我的一些图像/文件,但到目前为止还不是全部。我仍然有一个未缓存的文件列表(.jpg、.js 和 .css - 我知道我没有将 css 文件设置为在此处缓存)。Chrome审核中的消息只是说明The following resources are missing a cache expiration. Resources that do not specify an expiration may not be cached by browsers:
一些未缓存的图像是背景图像,其他图像是 js 库的一部分,它们是通过 JS 调用的——这会影响它们为什么不缓存吗?
抱歉,我无法提供代码链接 - 网站仍处于保密状态,仅限于客户端视图。
提前致谢!