Search code examples
favicon

Favicon displaying without being set


I have a rails-backbone application in which there is a file favicon.ico inside /public/images directory. I have searched my entire codebase but have not found a single instance where this image is being referred. But this image is set on the top left of the browser tab (like a favicon). Can anybody tell how can this happen.

I am sure this image is being used because of two reasons:
1. If I delete this, no image is shown.
2. If I replace this with some other image, the new image is shown.

Any help would be appreciated ! :)


Solution

  • Favicons are automatically recognized by all web browsers and they are not specific to any web framework. It is not required that you place them in the root directory (or in this case, public/images/ folder), but it is common practice to ensure that all browsers will find and recognize them.

    Specifically in Rails, you should use the favicon_link_tag to serve your favicons:

    If a page has no link like the one generated by this helper, browsers ask for /favicon.ico automatically, and cache the file if the request succeeds. If the favicon changes it is hard to get it updated.

    To have better control applications may let the asset pipeline manage their favicon storing the file under app/assets/images, and using this helper to generate its corresponding link tag.

    http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-favicon_link_tag