seadfeng / favicon-downloader

https://www.faviconextractor.com
MIT License
210 stars 21 forks source link

features request #11

Closed hausen1012 closed 1 month ago

hausen1012 commented 2 months ago

Thank you very much for developing such a user-friendly program

I use the favicon downloader as a way to obtain navigation website icons, but I have three questions when using it.

  1. Due to my navigation website having a large collection of websites, icon display is very slow when there are a large number of requests

I personally think that this can be done using caching. When a favicon downloader requests an icon, it will cache the icon locally, wait for the next request, and return directly. Of course, this cache also has a time limit, such as setting how many days it will be automatically cleared.

  1. I hope to add a request method that carries suffixes

For example https://favicon.153224.xyz/favicon/www.amjun.com When this request https://favicon.153224.xyz/favicon/www.amjun.com.png It can also respond correctly, so that when the first request is initiated and the browser requests again later, there will be cache, so there is no need to request the server. Of course, this can actually be solved through nginx configuration.

  1. When my website is an internal IP address, I cannot obtain the icon

Even though I knew it was normal to not be able to obtain it, at that time I thought it was possible to return a default icon?

image

I'm not sure if some of the above issues can be resolved. Looking forward to your reply

seadfeng commented 2 months ago

Thank you very much for developing such a user-friendly program

I use the favicon downloader as a way to obtain navigation website icons, but I have three questions when using it.

  1. Due to my navigation website having a large collection of websites, icon display is very slow when there are a large number of requests

I personally think that this can be done using caching. When a favicon downloader requests an icon, it will cache the icon locally, wait for the next request, and return directly. Of course, this cache also has a time limit, such as setting how many days it will be automatically cleared.

  1. I hope to add a request method that carries suffixes

For example https://favicon.153224.xyz/favicon/www.amjun.com When this request https://favicon.153224.xyz/favicon/www.amjun.com.png It can also respond correctly, so that when the first request is initiated and the browser requests again later, there will be cache, so there is no need to request the server. Of course, this can actually be solved through nginx configuration.

  1. When my website is an internal IP address, I cannot obtain the icon

Even though I knew it was normal to not be able to obtain it, at that time I thought it was possible to return a default icon?

image

I'm not sure if some of the above issues can be resolved. Looking forward to your reply

Images are recommended to use lazy loading, and images are loaded to ensure speed, it is recommended to use the https://github.com/seadfeng/favicons-proxy repository, directly copy the code to workers deployment can be, this version does not use web scraper, just proxy, so the speed is very fast.

Want to cache images to the server, please solve the problem by yourself, this tool mainly runs on cloudflare pages, edge function is not support image storage, need additional S3 storage to support ;

However, running in docker nodejs does not have this limitation, you can expand according to demand

hausen1012 commented 2 months ago

I understand, thank you

hausen1012 commented 1 month ago

Even if it cannot be stored, I still think there are two requests to see if they can be added.

  1. Requests can be made by adding a suffix. Like https://api.iowen.cn/favicon/www.amjun.com.png This request, check if it has a png suffix, remove the suffix before requesting the website icon
  2. When the requested domain name is invalid, return the default image instead of 400 For example, when there is an internal network address in the navigation, there will be no request failure
seadfeng commented 1 month ago

Even if it cannot be stored, I still think there are two requests to see if they can be added.

  1. Requests can be made by adding a suffix. Like https://api.iowen.cn/favicon/www.amjun.com.png This request, check if it has a png suffix, remove the suffix before requesting the website icon
  2. When the requested domain name is invalid, return the default image instead of 400 For example, when there is an internal network address in the navigation, there will be no request failure

1.source image may be gif, jpg or others, So using png as a suffix is not appropriate .

  1. return changed: https://39e48098.favicon-3j1.pages.dev/favicon/11.11
hausen1012 commented 1 month ago

ok,Can special treatment be given to these suffixes?

seadfeng commented 1 month ago

ok,Can special treatment be given to these suffixes?

https://github.com/seadfeng/favicon-downloader/blob/rewrites/next.config.mjs

Try changing it like this.

{
        source: '/favicon/:domain((?:[a-z0-9-]+\\.)+[a-z0-9]{1,}).png',
        destination: '/favicon/:domain',
}
hausen1012 commented 1 month ago

ok,Can special treatment be given to these suffixes?

https://github.com/seadfeng/favicon-downloader/blob/rewrites/next.config.mjs

Try changing it like this.

{
        source: '/favicon/:domain((?:[a-z0-9-]+\\.)+[a-z0-9]{1,}).png',
        destination: '/favicon/:domain',
}

thanks