Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Selectively delete Safari favicons from the icon cache Web Browsers
I updated the favorite icon (favicon.ico) on my web site, just to find that Safari insists the old one is good enough, even though other browsers are smart enough to show the new one. After some time spent here at macosxhints and other sites, I learned enough about how the Safari icon cache works to write this useful little shell script that works just fine with Safari 1.2.4. Remember to make the script executable (chmod +x script_name), and quit Safari before trying to use it.

I encourage folk to pop over to my Ask Dave Taylor site, where I talk about the process of writing and using this script in great detail in the article Can I selectively remove Safari favicon icons?.

[robg adds: The tenacity of Safari's hold on cached icons is one of my biggest complaints about the browser; this script makes it very easy to clear only those icons you'd like to reload -- thanks Dave!]
    •    
  • Currently 2.80 / 5
  You rated: 2 / 5 (5 votes cast)
 
[15,251 views]  

Selectively delete Safari favicons from the icon cache | 12 comments | Create New Account
Click here to return to the 'Selectively delete Safari favicons from the icon cache' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Selectively delete Safari favicons from the icon cache
Authored by: daybrother on Dec 23, '04 10:15:52AM

This is actually quite odd. My problem is the reverse: Every now and then, for no particular reason, all of my favicons disappear. Some come right back when I revisit a site but others won't come back for a day, a week, a month, and then, suddenly, they start reappearing. Then, one day, they all disappear again at once. Don't know why but it has been happening for about a year now.



[ Reply to This | # ]
Selectively delete Safari favicons from the icon cache
Authored by: d1taylor on Dec 23, '04 10:32:24AM
Not sure this is the solution, but what permission does your ~/Library/Safari/icons directory have? Use this command:
$ ls -ld ~/Library/Safari/icons
drwx------  18 taylor  staff  612 11 Apr  2004 /Users/taylor/Library/Safari/icons/
This being set wrong could cause Safari to stumble...

[ Reply to This | # ]
Selectively delete Safari favicons from the icon cache
Authored by: daybrother on Dec 24, '04 12:35:57AM
Thanks, but I get the same permissions result. It is something else I think....just don't know what. I've noticed a lot of little glitches as Panther has grown and so I expect it is within the OS security and not Safari. A minor annoyance--I still prefer and use Safari as my main browser. Just the other night I realized that even with a symlink in /WebServer/Documents you can't really set a personal web page in ~user/Sites anymore, and I am absolutely sure that I did that just last year.

[ Reply to This | # ]
Selectively delete Safari favicons from the icon cache
Authored by: hypert on Dec 23, '04 12:45:30PM
Excellent hint, and very nicely-written script. One comment - please use mktemp to create temporary files, as discussed before.

[ Reply to This | # ]
Selectively delete Safari favicons from the icon cache
Authored by: kps on Dec 27, '04 01:53:12PM
Actually, it's horribly written. That temporary file is completely unnecessary in the first place. So is the extra grep used to remove the error messages that result from applying the useful grep to directories (clue: find -type f). So is the gratuitous cut to select the file name from the grep output (clue: grep -l).

I wouldn't normally pick on a neophyte's clumsy mistakes, but the author of this script is actually selling a book on writing shell scripts! Ignorance is no vice; packaging it as wisdom is.

[ Reply to This | # ]

Selectively delete Safari favicons from the icon cache
Authored by: peragrin on Dec 23, '04 03:35:57PM

Safari has one other " feature" that makes it so I don't use Safari as often as I would like.

Why does Apple store their book marks as XML files and then makes importing and exporting them a pain.

Why do I care? Well I use three different computers all with the same bookmarks, when ever i update the bookmarks, I upload the Firefox(mozilla) HTML file to my website. I can view them online, or I can easily download the updated files. Since I use windows, Linux, and OS X(gaming, Server, & Primary(powerbook)) I need to be able to use my bookmarks easily.

Konqueror from KDE makes updates easy. three mouse clicks. In Safari I have to activate the debug menu(actually I haven't turned it off), import, then manually edit the bookmarks to add in updates.

heck even a simple import/export utility would make my day.

---
I thought once I was found but it was only a dream



[ Reply to This | # ]
Selectively delete Safari favicons from the icon cache
Authored by: snit on Dec 23, '04 11:47:05PM

Two solutions:

- Turn on the "debug" menu and it includes an "export" function... which exports to HTML

- use the freeware "Safari Bookmark Exporter", and it will let you export your bookmarks in a number of formats - OmniWeb, OmniWeb 5, IE, Camino, Mozilla, Firefox, iCab, Opera, etc.
[http://homepage.mac.com/simx/]



[ Reply to This | # ]
Selectively delete Safari favicons from the icon cache
Authored by: futerfas on Dec 23, '04 03:56:10PM

This may sound like a dumb question, but how do you get that script from a text file into a script. I never was able to get these to work. Thanks.



[ Reply to This | # ]
Selectively delete Safari favicons from the icon cache
Authored by: hypert on Dec 23, '04 10:36:09PM
I spoke too soon previously - I had only looked at the code and hadn't run it yet. This script is broken on my machine. This may be futerfas' problem, too. Change the line icondir="$HOME/Library/Safari/icons" to icondir="$HOME/Library/Safari/Icons" (capital "I" in "Icons"), if that's really the name of your icon/Icon dir.

Also, change temp="/tmp/$0.$$" to temp=`mktemp`

One more thing. I used the "strings" command to look through some of the files that would have been deleted. It looks like the favicons for more than one site can be stored in each of those files. So, you may purge more favicons than you meant to!

[ Reply to This | # ]

Selectively delete Safari favicons from the icon cache
Authored by: ken22 on Dec 24, '04 02:05:31AM

Copy and paste the text into Apple's Script Editor, the compile.



[ Reply to This | # ]
Selectively delete Safari favicons from the icon cache
Authored by: futerfas on Dec 24, '04 11:46:46AM

Thank you! I've been trying to do this in text edit lol



[ Reply to This | # ]
Selectively delete Safari favicons from the icon cache
Authored by: johnq on Dec 25, '04 05:24:02AM

>>Copy and paste the text into Apple's Script Editor, the compile.<<

Is that a cruel joke? The code is not in AppleScript. It is a shell script. :/



[ Reply to This | # ]