Hi, I’ve made an ASS program to act a a little video player, streaming films from my studio to my laptop using webview. It works great, I have a searchable database of a few 100 clips which stream very nicely. However… what I’m noticing is that the movies seems to build up in the cache, which is good in a sense that I can go back to a film I’ve already watched and it’s there in it’s entirety without having to stream. What’s not so good about it is my harddrive rapidly starts running out of room, a dozen clips later and I can see a 1 gig reduction is diskspace which on my poor laptop is enough to worry about. So my question is, is there a way to limit or clear the cache that the webview is using? Any help would be greatly appriciated.
Perhaps someone who knows more about call method and Objective-C can make use of the “setPrivateBrowsingEnabled:” method (of the preferences of the webview). However, that would stop caching completely.
The cache is probably kept in /Library/Caches or ~/Library/Caches. If you use List view with Date selected in a Finder window, you’ll be able to tell which. You might then trash it from your script or even write a handler to check for the most recent file in whichever library it is and when it gets to a certain size, dump it.
I didn’t think about that Adam. I checked a webview app I made, and it’s cache is stored in ~/Library/Caches/ApplicationName.
Excellent advice, thank you, given me something to work on.
This is a script I use to find out which Safari cache is active:
tell application "Finder"
set Caches to ((path to library folder from user domain as text) & "Caches:Safari:") as alias
set CF to items of Caches
set F to modification date of items of Caches
set Std to date "Monday, January 1, 1900 12:00:00 AM"
set nearest to 0
repeat with d from 1 to count F
if (item d of F) - Std > 0 then set nearest to d
set newest to (item d of CF) as alias
if button returned of (display dialog "Do you want to delete this cache folder?") is "OK" then delete newest
Cool, thanks. On further analysis it’s actually the quicktime cache that’s eating all the memory (which makes sense), your script looks perfect to try and get rid of it, thank you.
More than welcome - happy scripting.