Search code examples
playframeworkfavicon

Play framework favicon issue


I have searched a lot about this issue, but all solutions in Google forum and here won't fix it, probably because they related to older Play version.

No matter how I modify the link tag

<link rel="Shortcut Icon" href='@routes.Assets.at("images/favicon.ico")' >

or modify route as suggested in other solutions, I always get the default green triangle icon shown in the browser. I even removed this icon but it's still displayed. Browser cache is cleared, I don't know what else I can do. Any help would be great.


Solution

  • Change routes to:

    GET     /favicon.ico    controllers.Assets.at(path="/public/images", file="yourimage.png")
    

    Every browser is trying to get favicon by requesting it via /favicon.ico, so you can point it to your page there.

    You can request/check your favicon doing this:

    http://127.0.0.1:9000/favicon.ico
    

    So if that works (request above) it means that it is most likely cache issue.

    You can also read about how to use Assets on here: The Assets controller

    I guess you are using OSX with Chrome and if so you need to clear favicon's cache. Please try next steps:

    /Users/you/Library/Application Support/Google/Chrome/Default/Favcions
    

    Restart your Chrome (in case if that does not help, try to delete journal as well and restart Chrome again).

    /Users/you/Library/Application Support/Google/Chrome/Default/Favcions-journal
    

    If you use another OS, I'm sure you will find in the google how to clear cache of favicons.