Remove Etag from favicon.ico

2019-03-29 07:46发布

问题:

using yslow on a project I am experiencing a "problem" I can not solve.

Yslow keeps complaining:

There is 1 component with misconfigured ETags http://www.domain.com/favicon.ico

I have the following in my .htaccess file

# Add Proper MIME-Type for Favicon
AddType image/x-icon .ico

# Enable Apache's mod_expires Module
ExpiresActive On
ExpiresByType image/x-icon "access plus 6 month"

<ifModule mod_headers.c>
  Header unset ETag
</ifModule>
FileETag None

Does anybody have an idea how to fix it?

回答1:

Add this:

ExpiresByType image/ico "access plus 1 years"

My .htaccess file:

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault A0
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/ico "access plus 1 month"
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType text/javascript "access plus 1 week"
    ExpiresByType application/javascript "access plus 1 week"
    ExpiresByType application/x-javascript "access plus 1 week"
    ExpiresByType image/x-icon "access plus 1 year"
    ExpiresByType image/ico "access plus 1 years"
</IfModule>

Header unset ETag
FileETag None


回答2:

Hmmm. this did not fix the issue for me in Drupal ( 7 ).

Adding these lines to my .htaccess file:

  ExpiresActive On
  ExpiresByType image/x-icon A604800

Also added this line to my apache http config: (but can also be in your .htaccess file)

  FileETag None

And i disabled the icon / default icon on the admin/appearance/settings/[theme_name] page.

And finally copied the favicon.ico file to my site root and this DID fix this problem for me.

Kinda looks like something is wrong in Drupal here? :/



回答3:

none above helped for me but this works excellent:

<FilesMatch "favicon.ico">
    Header unset ETag
    FileETag None
</FilesMatch>