3

We're seeing a consistent pattern across speed tests on GT Metrix for a site where there is a 150-250ms gap between all resources loading and then the favicon request initializing. This is extending the fully loaded time.

Any ideas why this might be happenening?

Favicon is referenced in the head of the HTML file as follows:

<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"> 

The Drupal 7 .htaccess file refers to favicon as follows:

# Pass all requests not referring directly to files in the filesystem to
# index.php. Clean URLs are handled in drupal_environment_initialize().
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]

Screenshot of waterfall (note gap between penultimate and last request): waterfall diagram of site speed

slawrence10
  • 202
  • 1
  • 20
  • Are you seeing this with this specific site only? How did you embed/refer to the favicon? Did you specify it at all - or are you just relying on the mechanism, that browsers automatically request `/favicon.ico` when a favicon has _not_ been explicitly specified? – CBroe Feb 26 '18 at 10:37
  • Favicon is referenced as follows in head of doc: Yes I'm seeing it on more than one site. Could it be an apache issue? – slawrence10 Feb 26 '18 at 11:08
  • Is it possible for you to check also the access log? I have seen some strange request behavior exactly for favicon. – Andra Feb 26 '18 at 19:40
  • Hey @Andra I looked at the access log, but not sure what would suggest strange behaviour? I've updated the question to include part of the .htaccess file. Not sure if the rule could be creating delay?...though surely it would delay all files... – slawrence10 Feb 28 '18 at 01:02
  • Are you sure you need this rule (`RewriteCond %{REQUEST_URI} !=/favicon.ico`) at all? – Andra Feb 28 '18 at 10:57
  • for example, maybe you can see in access.log multiple requests for favicon and ongoing redirecting (of such requests) – Andra Feb 28 '18 at 11:01

1 Answers1

1

This is because the favicon is not needed to actually render the page, only to display in the title bar, so browsers postpone downloading it.

(I'm curious myself if it can be force-loaded quicker, apparently it's not trivial at all, even with preload or http/2 push it would just be loaded twice)

lucian
  • 623
  • 10
  • 21