Use this script to clear Safari Cache:
--Empty Safari Cache (v1)
--NB: Save as application
---------------------------------------------
(*==========PROPERTIES==========*)
property path2home : (path to home folder)
property TargetFileName : "Cache.db"
property TargetFileLocation : (path2home & "Library:Caches:com.apple.Safari:") as text
property TargetFile : TargetFileLocation & TargetFileName
property mytitle : "Empty Safari Cache"
(*==========SCRIPT==========*)
--check if Safari is running
set SafariRunning to false
tell application "Finder" to get name of processes
set application_list to result
if application_list contains "Safari" is true then
set SafariRunning to true
end if
--dialog
display dialog "Empty Safari Cache?" default button 2 --with icon 1
--quit Safari first!
if SafariRunning is true then
display dialog "Quit Safari to continue!" buttons {"Cancel", "OK"} default button 2 with icon 0
end if
tell application "Safari" to quit
delay 1
--trash file
tell application "Finder"
if exists file TargetFile then
deleteTargetFile
tell me
display dialog "Cache emptied." buttons {"Launch Safari", "Done"} default button 2 --with icon 1 with title mytitle
set button_returned to button returned of the result
end tell
else
tell me
display dialog "Cache already empty!" buttons {"Launch Safari", "Done"} default button 2 --with icon 1 with title mytitle
set button_returned to button returned of the result
end tell
end if
end tell
--relaunch Safari
if button_returned is "Launch Safari" then
tell application "Safari" to activate
end if
(*==========END==========*)