What and why is "Webpage Previews?"
|
Joined: Aug 2009
Likes: 15
|
OP
Joined: Aug 2009
Likes: 15 |
It's located at ~/Library/Caches/com.apple.Safari/Webpage Previews, neither clearing either Safari's history or cache nor restarting clears it, it stores both .jpeg and .png images of each web page, and I've seen it grow to more than 50Mb. (I guess it's time to give it its head and see if it purges itself at some point.)
I don't think it's the spawn of anything I've ever run on my deuced Mac(hina)...certainly nothing I'm running now other than, I guess, Safari, in which case, why doesn't Safari clean up after itself?
Last edited by artie505; 11/17/10 08:07 AM. Reason: Cleanup
The new Great Equalizer is the SEND button.
In Memory of Harv: Those who can make you believe absurdities can make you commit atrocities. ~Voltaire
|
|
Re: What and why is "Webpage Previews?"
|
Joined: Aug 2009
Likes: 7
|
Joined: Aug 2009
Likes: 7 |
I can't explain it either but I can confirm your observation. That folder is 11 MB in my system. I don't know how big it was originally (your post is the first that I knew of this) but clearing the Safari cache had no effect. I don't want to clear the Safari history because I want to keep it.
Jon
macOS 11.7.10, iMac Retina 5K 27-inch, late 2014, 3.5 GHz Intel Core i5, 1 TB fusion drive, 16 GB RAM, Epson SureColor P600, Photoshop CC, Lightroom CC, MS Office 365
|
|
Re: What and why is "Webpage Previews?"
|
Joined: Aug 2009
Likes: 15
|
OP
Joined: Aug 2009
Likes: 15 |
I can't explain it either but I can confirm your observation. That folder is 11 MB in my system. I don't know how big it was originally (your post is the first that I knew of this) but clearing the Safari cache had no effect. I don't want to clear the Safari history because I want to keep it. As I said, Jon, nothing I do with Safari has any effect on that file other than making it grow larger; I either clear it manually or let Yasu take care of it (although I have no idea why Yasu clears something that Safari, itself, doesn't clear). I'm going to let mine run for a while and see how big it gets and whether it clears itself at some point. What really mystifies me is why it saves its contents as both jpegs and pngs?
The new Great Equalizer is the SEND button.
In Memory of Harv: Those who can make you believe absurdities can make you commit atrocities. ~Voltaire
|
|
Re: What and why is "Webpage Previews?"
|
Joined: Aug 2009
Likes: 15
|
OP
Joined: Aug 2009
Likes: 15 |
I just did some searching and found that the issue goes back to at least early 2009...Safari 4 (with Hal involved in a discussion at Ars Technica in which file sizes on the order of 2-3 Gb were reported); it apparently has something to do with Safari's "Top Sites" feature. I also found this "fix".
Last edited by artie505; 11/17/10 11:51 AM. Reason: xpanded first paragraph
The new Great Equalizer is the SEND button.
In Memory of Harv: Those who can make you believe absurdities can make you commit atrocities. ~Voltaire
|
|
Re: What and why is "Webpage Previews?"
|
Joined: Aug 2009
Likes: 3
Moderator
|
Moderator
Joined: Aug 2009
Likes: 3 |
I think the purpose of that folder is to maintain a cache of webpage images used by Safari's Top Sites and visual (i.e. Cover Flow) history features. You can delete the folder's contents by going to the Safari menu, choosing Reset Safari..., and unchecking all but the Remove all webpage preview images checkbox, then clicking the Reset button.
It's just as easy to select the folder in Finder and move it to the Trash; it'll be regenerated on Safari's next launch. Interestingly, if upon relaunch you open Safari's History -> Top Sites page, the recreated folder will re-populate itself with images of a default set of sites, pair by pair, as the pages are loaded into Top Sites and captured as images.
As for the dual sets of images, if you open any of them, you'll find that the jpegs are smaller thumbnail images, and the pngs are full-size screen captures; it appears that the former are used for the display of images in Top Sites or Cover Flow history pages, and the latter are used as full-size temporary placeholders for live content if you click on a Top Sites image.
There appear to be multiple techniques for disabling the caching of such images; locking the Webpage Previews folder is one which I tried, and which seems (so far) to be working.
dkmarsh—member, FineTunedMac Co-op Board of Directors
|
|
Re: What and why is "Webpage Previews?"
|
Joined: Aug 2009
Likes: 3
Moderator
|
Moderator
Joined: Aug 2009
Likes: 3 |
An AppleScript solution. set thePath to ((path to library folder from user domain) as Unicode text) & "Caches:com.apple.Safari:Webpage Previews"
tell application "Finder"
if (exists folder thePath) then
delete folder thePath --move "Webpage Previews" to Trash
else
display dialog "Folder doesn't exist."
end if
end tell
dkmarsh—member, FineTunedMac Co-op Board of Directors
|
|
Re: What and why is "Webpage Previews?"
|
|
Joined: Aug 2009
|
To also create an empty locked folder: set theLocation to ((path to library folder from user domain) as Unicode text) & "Caches:com.apple.Safari"
set thePath to theLocation & ":Webpage Previews"
tell application "Finder"
if (exists folder thePath) then
delete folder thePath --move old "Webpage Previews" to Trash
else
display dialog "Folder doesn't exist."
end if
tell folder theLocation
make new folder with properties {name:"Webpage Previews", locked:true}
end tell
end tell
|
|
Re: What and why is "Webpage Previews?"
|
Joined: Aug 2009
Likes: 15
|
OP
Joined: Aug 2009
Likes: 15 |
Thanks for the clarification.
Locking the empty folder is working for me, too, so far. (I totally forgot to look at the "Reset" pane, but, under any circumstances, I find it too cumbersome to work with.)
Don't you think it's kind of odd that a cache that can grow to a humongous size is more or less shrouded in secrecy?
The new Great Equalizer is the SEND button.
In Memory of Harv: Those who can make you believe absurdities can make you commit atrocities. ~Voltaire
|
|
Re: What and why is "Webpage Previews?"
|
Joined: Aug 2009
Likes: 14
|
Joined: Aug 2009
Likes: 14 |
".... and I've seen it grow to more than 50Mb. I've been following this thread so, out of curiosity, I checked the size of that folder on my drive. It's 577.6 MB, but I still have nearly 270 GB of space on a 320 GB drive, so I guess I'm a ways away from needing to be concerned. ryck
Last edited by ryck; 11/17/10 11:07 PM.
ryck
"What Were Once Vices Are Now Habits" The Doobie Brothers
iMac (Retina 5K, 27", 2020), 3.8 GHz 8 Core Intel Core i7, 8GB RAM, 2667 MHz DDR4 OS Ventura 13.6.3 Canon Pixma TR 8520 Printer Epson Perfection V500 Photo Scanner c/w VueScan software TM on 1TB LaCie USB-C
|
|
Re: What and why is "Webpage Previews?"
|
Joined: Aug 2009
Likes: 5
Moderator
|
Moderator
Joined: Aug 2009
Likes: 5 |
An alternative Finder solution would be to get Info on the folder after having dragged the contents to the trash, then simply change the Sharing & Permissions parameters to "Read Only" for yourself as owner and leave the already set parameters for everyone to be "No Access" as it currently is set.....the end result is the same as locking the folder.....
So, navigate into your Home directory /Caches/apple.com.safari/Webpage Previews and drag the contents to the trash and then empty the trash......next, navigate one level up into the com.apple.safari folder and highlight the Webpage Previews folder then either use the Command I keyboard combo or pull down the File Menu to select the Get Info option and then change the owner's (your) permissions from "Read & Write" to "Read Only".....now that folder will no longer accept any further input until you change it back to "Read & Write".
Freedom is never free....thank a Service member today.
|
|
Re: What and why is "Webpage Previews?"
|
Joined: Aug 2009
Likes: 15
|
OP
Joined: Aug 2009
Likes: 15 |
I've tried both locking the folder and changing permissions on it, and both approaches have unhappily resulted in many Console entries such as this one: 11/20/10 2:13:48 AM [0x0-0x15b15b].com.apple.Safari[1253] ImageIO: could not open '/Users/artie/Library/Caches/com.apple.Safari/Webpage Previews/.532AF04D3CB00E5E21C6A7A2B5387722.png-48LM' (At the moment, "1079 of 4000 messages from 11/17/10 6:15:06PM to 11/20/10 2:14:06AM" are variations of that message.) Both AppleScripts that have been posted both look like they'll leave me in the same position, so I'm wondering whether there's any way to both have my cake and eat it, i.e. prevent the images from being created/cached and not see all those Console messages? Thanks.
The new Great Equalizer is the SEND button.
In Memory of Harv: Those who can make you believe absurdities can make you commit atrocities. ~Voltaire
|
|
Re: What and why is "Webpage Previews?"
|
|
Joined: Sep 2009
|
so I'm wondering whether there's any way to both have my cake and eat it, i.e. prevent the images from being created/cached and not see all those Console messages? A periodic script to nuke them is probably the easiest: rm -f ~/Library/Caches/com.apple.Safari/Webpage\ Previews/*
Use launchd to drive it (or an AppleScript scheduled with iCal maybe). -- Hmm, launchd is a pain sometimes. It won't operate in such a way that allows using the tilde ( ~) or the asterisk ( *) like we can on the command line, and in scripts. So we can't feed it that exact line (which only removes files), but instead we would have to remove the whole folder. [i.e., if we were going for a " launchd-only" solution.] And i'm not sure how Safari will act if the folder is there one minute and gone the next. So the way we'd need to do it is to put that command in a shell script, and then call that script with launchd.
Last edited by Hal Itosis; 11/20/10 08:33 PM.
|
|
Re: What and why is "Webpage Previews?"
|
|
Joined: Aug 2009
|
You can do it with launchd, if you must. There are two ways:
<key>ProgramArguments</key>
<array>
<string>/bin/rm</string>
<string>-f</string>
<string>~/Library/Caches/com.apple.Sarari/Webpage Previews/*</string>
</array>
<key>EnableGlobbing</key>
<true/> or
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>rm -f ~/Library/Caches/com.apple.Safari/Webpage\ Previews/*</string>
</array> Note that in the first form the space in "Webpage Previews" should not be escaped, since the whole point of specifying ProgramArguments as an array is to describe the end result after shell expansion, so that word splitting and quote removal have already been done. (EnableGlobbing has the side effect of forcing another round of quote removal, so escaping the space will do no harm, but you should not get in the habit of doing unnecessary quoting. In the absence of EnableGlobbing, any quoting characters will be passed along to the process being launched.) In the second form, on the other hand, we're introducing another copy of the shell, which will do all the normal command-line expansion, so normal command-line quoting rules apply. But perhaps easier would be eschew launchd and use Folder Actions instead: on adding folder items to this_folder after receiving added_items
repeat with afile in added_items
tell application "System Events"
delete afile
end tell
end repeat
end adding folder items to Note that you tell System Events to delete the files. If you tell Finder to delete them, it'll just move them to the Trash, cluttering up your Trash. (I hate it when programs do that. It's my Trash, for files I delete.)
|
|
Re: What and why is "Webpage Previews?"
|
Joined: Aug 2009
Likes: 15
|
OP
Joined: Aug 2009
Likes: 15 |
Thanks for the script, but I've followed every instruction I can find (*) and can't get the Folder Action to run... 11/21/10 2:41:32 AM com.apple.launchd.peruser.501[125] (com.apple.FolderActions.folders) Throttling respawn: Will start in 10 seconds Any ideas? Addendum: I tried saving the script both with and without checking the "Run Only" box...no difference. (*) Being more specific... - I compiled your script
- I saved it, both ways, as mentioned, to ~/Library/Scripts/Folder Action Scripts
- I enabled the Folder Action by control-clicking on ~/Library/Caches/com.apple.Safari/Webpage Previews and following the instructions.
Last edited by artie505; 11/21/10 07:26 AM.
The new Great Equalizer is the SEND button.
In Memory of Harv: Those who can make you believe absurdities can make you commit atrocities. ~Voltaire
|
|
Re: What and why is "Webpage Previews?"
|
|
Joined: Sep 2009
|
You can do it with launchd, if you must. There are two ways: <key>EnableGlobbing</key>
<true/> Ah-ha... sneaky. [i' didn't yet delve into that globbing discussion over at macosxhints. Now that i've seen * this* example, i shalll remember it.] <string>/bin/bash</string>
<string>-c</string> Also slick (and makes sense). Thanks. Note that in the first form the space in "Webpage Previews" should not be escaped, since the whole point of specifying ProgramArguments as an array is to describe the end result after shell expansion, so that word splitting and quote removal have already been done. (EnableGlobbing has the side effect of forcing another round of quote removal, so escaping the space will do no harm, but you should not get in the habit of doing unnecessary quoting. In the absence of EnableGlobbing, any quoting characters will be passed along to the process being launched.) In the second form, on the other hand, we're introducing another copy of the shell, which will do all the normal command-line expansion, so normal command-line quoting rules apply. Argh... my head hurts. [but i got most of it.]
|
|
Re: What and why is "Webpage Previews?"
|
|
Joined: Aug 2009
|
It looks like the folder action is encountering an error. It may be a race condition; it's trying to delete a file that is still being created, or maybe already in use after being created. The script is certainly being too aggressive. The problem we're trying to address is not so much that the Web Previews folder has anything in it, as that what's being put there never gets cleaned out. Let's solve the race condition by only deleting old files: on adding folder items to thisFolder after receiving someFiles
set folderPath to quoted form of POSIX path of thisFolder
do shell script "cd " & folderPath & "; find . -atime +24h -delete"
end adding folder items to In this version, every time anything is added to the folder we'll delete anything that hasn't been accessed in the last 24 hours. If Safari hasn't used one of these files recently, it probably won't need it soon. Conversely, if it has used something recently and we delete it, it'll probably re-create it soon, which only wastes cycles. For testing purposes, I duplicated the Web Previews folder and set the folder action on that. I also had to replace -atime with -mtime (modify time rather than access time) because the act of copying the folder accessed all the items. You might also need to use -mtime instead of -atime, but don't do that until you've run it for a couple of days and find that it isn't deleting enough. Even if Safari isn't modifying a file, if it's even using it it's doing some good.
|
|
Re: What and why is "Webpage Previews?"
|
Joined: Aug 2009
Likes: 3
Moderator
|
Moderator
Joined: Aug 2009
Likes: 3 |
Note that you tell System Events to delete the files. If you tell Finder to delete them, it'll just move them to the Trash, cluttering up your Trash. (I hate it when programs do that. It's my Trash, for files I delete.) You can tell Finder to delete the files, then send it the empty command, but of course this risks throwing out the baby with the bathwater for folks who use the Trash to hang on to items they're not quite ready to nuke. Another way around the Console error issue is simply to quit Safari with a script which deletes the folder or its contents: set thePath to ((path to library folder from user domain) as Unicode text) & "Caches:com.apple.Safari:Webpage Previews"
tell application "Finder"
delete folder thePath --move "Webpage Previews" to Trash
empty --warning: empties the Trash! Delete this line if you use the Trash to store stuff!
end tell
tell application "Safari" to quit Or use System Events for the deletion. The point is that quitting (or launching) an app with an AppleScript script is an easy way to perform tasks which don't need to happen on a schedule as long as they happen more or less regularly. (Of course, this doesn't work if you're always up and never quit Safari, but I've never had so much RAM that Safari couldn't benefit from an occasional relaunch, even now that its memory leaks seem to be a thing of the past.)
dkmarsh—member, FineTunedMac Co-op Board of Directors
|
|
Re: What and why is "Webpage Previews?"
|
Joined: Aug 2009
Likes: 15
|
OP
Joined: Aug 2009
Likes: 15 |
Thanks for the update, but I've run into a new issue (which either didn't show up immediately or went unnoticed ), wherein every time a Folder Action is invoked it causes Safari's tool and bookmarks bars to "flash," which I find unacceptable. In addition, after giving the matter some thought I've realized that none of the solutions offered up so far deals with my situation... I never use either Top Sites or Cover Flow, and rather than deleting Webpage Previews that have already been cached I prefer that they never be created in the first place. So... I went back to Google and found Disable Webpage Preview Images in Safari 4 Final, which is working like a dream in Safari 5.0.3. To all who've kicked in, thanks, and to all who are waiting with baited breath, go for it!
Last edited by artie505; 11/23/10 06:51 AM.
The new Great Equalizer is the SEND button.
In Memory of Harv: Those who can make you believe absurdities can make you commit atrocities. ~Voltaire
|
|
|
|