Is there a way I can set Safari to clear cache and cookies on startup? Maybe a flag I could use when launching the application, or perhaps even a bash or applescript that would delete files on the hard drive and then launch the app?
Use the following AppleScript code and save it e.g. as an application in AppleScript Editor, or as a Service consisting of a single Run AppleScript action in Automator.
This will activate Safari, launching it if it's not running, and then open and submit the "Reset Safari…" menu item.
Hope this helps ... new to the Applescript thing myself but I put these together from looking over other examples like the one above this.
These scripts are saved as applications. Perhaps instead of saving as an application,creating these as a Service off of the finder menu... maybe with a keyboard short cut would be a good thing too.
The first script (Safari ON) will open Safari in private browsing mode... then reset safari ...then clear the cache.
The second script (Safari OFF) will reset safari... clear the cache.. then close safari.
They both seemed to work fine for me but like I said... I'm new to this, I've only been at it for two days.
If you find the scripts incorrectly done... or can improve them in some way feel free to post any recommended changes for everyone.
To do the same thing but on close:
Isn't it easier to use safari in private browsing mode, in that way, no info is kept in the first place
To make safari start with private browsing enabled follow the following step
Here is my version of a clear history script for Safari. As it is I have it setup for German, but it can easily be modified.
Completely automates the deletion of history under the history menu and top sites (this can be toggled by removing the