The clearSafariCache.sh script takes a very long time (almost three minutes) on my machines, too, so I went ahead and optimized the find
expression a bit so it won't unnecessarily descend into huge directories like com.apple.metadata.mdworker
.
Just replace the line
find /private/var/folders \! -name "*SafariTechnologyPreview*" -name "*com.apple.Safari*" -exec rm -r {} \; 2>/dev/null
with
exec 2>/dev/null
find /private/var/folders -name "*SafariTechnologyPreview*" -prune -o -name "com.apple.Safari*" -print0 -o -name "com.apple.*" -prune | xargs -0 rm -r
Now the script finishes in less than a second.
(I know that Cookie 6 and later do no longer use this script at all, but people who are still on older systems and cling to Cookie 5 might benefit.)