Why am I getting error for apple-touch-icon-precomposed.png

后端 未结 11 1757
梦谈多话
梦谈多话 2020-11-29 16:06

I have created a new rails3 project but I am seeing following logs many times in my server logs. Why I am getting these request and how can I avoid these?

相关标签:
11条回答
  • 2020-11-29 16:15

    Try to change link from

    /apple-touch-icon-precomposed.png 
    

    to:

    <%=asset_path "apple-touch-icon-precomposed.png" %>
    
    0 讨论(0)
  • 2020-11-29 16:19

    There’s a gem like quiet_assets that will silence these errors in your logs if, like me, you didn’t want to have to add these files to your Rails app:

    https://github.com/davidcelis/quiet_safari

    0 讨论(0)
  • 2020-11-29 16:21

    I finally solved!! It's a Web Clip feature on Mac Devices. If a user want to add your website in Dock o Desktop it requests this icon.

    You may want users to be able to add your web application 
    or webpage link to the Home screen. These links, represented 
    by an icon, are called Web Clips. Follow these simple steps 
    to specify an icon to represent your web application or webpage
    on iOS.
    

    more info: https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html

    how to solve?: Add a icon to solve problem.

    0 讨论(0)
  • 2020-11-29 16:28

    If you don't care about the icon looking pretty on all sort of Apple devices, just add

    get '/:apple_touch_icon' => redirect('/icon.png'), constraints: { apple_touch_icon: /apple-touch-icon(-\d+x\d+)?(-precomposed)?\.png/ }

    to your config/routes.rb file and some icon.png to your public directory. Redirecting to 404.html instead of icon.png works too.

    0 讨论(0)
  • 2020-11-29 16:28

    Same thing is happening for me. And yes, as @Joao Leme said, it seems it is related to a user bookmarking a site to their device homescreen.

    However, I noticed that even though there is an error in the log, it's happening behind the scenes and the user never sees the error. I assume the device makes a request for the touch-icon specific to its resolution (which isn't there) until defaulting to the general apple-touch-icon or apple-touch-icon-precomposed, if present, or else generates a small screenshot of the current page.

    FWIW, put the icons in the /public directory.

    0 讨论(0)
  • 2020-11-29 16:29

    If a user from Safari Web browser (Apple devices) visit your site. The browser tries to fetch the site icon if it is not defined in <head> in the following order:

    1. apple-touch-icon-57x57-precomposed.png
    2. apple-touch-icon-57x57.png
    3. apple-touch-icon-precomposed.png
    4. apple-touch-icon.png

    To resolve this issue either define an icon for safari web browsers or apple devices. Add something like this to head section of your site:

    <link rel="apple-touch-icon" href="/custom_icon.png"/>
    

    If you want to keep <head> clean then upload the icon to root dir of your site with proper name.

    The default icon size is 57px.

    You can find more details on iOS developer library.

    0 讨论(0)
提交回复
热议问题