【问题标题】:How to cache my favicon如何缓存我的网站图标
【发布时间】:2011-08-09 01:06:54
【问题描述】:

我正在尝试将我的网站图标缓存为 yslow 建议。

我的图标是http://www.tucoaster.com/favicon.ico

出于某种原因,网站图标的内容类型是 text/plain。 我正在使用 apache2,在我的 .htaccess 中有

ExpiresByType text/plain "access plus 30 days"
ExpiresByType image/x-icon "access plus 30 days"
ExpiresByType image/ico "access plus 30 days"

注意:Javascript 和 css 标头发送正常。

有什么建议吗?

【问题讨论】:

    标签: html apache apache2


    【解决方案1】:

    Apache 可能不知道 ICO 格式的正确 MIME 类型。

    尝试添加

    AddType image/x-icon .ico
    

    ExpiresByType 指令之前。

    【讨论】:

    • 你是对的。要查看 Apache 认为 favicon.ico 的 MIME 类型是什么,请使用 webpagetest.org 对您的网页进行基准测试,然后单击“详细信息”并滚动到底部以查看获取 favicon.ico 时的响应标头。如果 .htaccess 中没有“AddType image/x-icon .ico”,Apache 会将我的 favicon.ico 报告为“Content-Type: image/vnd.microsoft.icon”而不是“Content-Type: image/x-icon”。
    • ExpiresDefault 而不是 ExpiresByType 怎么样?我正在使用 ExpiresDefault 并且 favicon.ico 仍未缓存。实际上,我的 index.html 中引用的任何内容都不会被缓存,而通过 requireJS 加载的其余内容会被正确缓存。我实际上完全没有想法......
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-01
    • 1970-01-01
    • 2020-06-05
    • 2016-06-24
    • 2020-03-29
    • 1970-01-01
    相关资源
    最近更新 更多