1
我試圖讓我的favicon cacheable as yslow suggets。如何緩存我的favicon
我的圖標是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頭被送到確定。
有什麼建議嗎?
你說得對。要查看Apache認爲MIME類型是用於favicon.ico的,請使用http://www.webpagetest.org/對您的網頁進行基準測試,然後單擊「詳細信息」並滾動到底部以查看favicon.ico時的響應頭被提取。如果在.htaccess中沒有「AddType image/x-icon .ico」,Apache會將我的favicon.ico報告爲「Content-Type:image/vnd.microsoft.icon」而不是「Content-Type:image/x-icon」。 – 2013-04-30 05:19:36
ExpiresDefault而不是ExpiresByType呢?我正在使用ExpiresDefault,而favicon.ico仍然沒有被緩存。實際上,我的index.html中引用的任何內容都不會被緩存,而通過requireJS加載的其他內容會被正確緩存。我其實完全沒有想法...... – 2015-08-21 08:49:34