Private Browsing with Safari

I use Firefox as my primary browser, both at home and at work. So I have setup my Safari browser, as my private browser – that is sans cache, history, cookies or anything of a similar nature. I noticed that the “Private Browsing” option in Safari, doesn’t do that good a job of not leaving files hanging around in one’s operating system, furthermore unless your careful, Spotlight will eventually end up indexing your browser history, cache, which may be less than ideal.

In order to have a zero cache safari instance on my laptop I have taken the following steps :

  • 1: Removed spotlight’s prying eyes, by excluding the following directories :
    • /Users/<USERDIR>/Library/Caches
    • /Users/<USERDIR>/Library/Safari
    • /Library/Caches
  • 2: Setup two cronjobs to constantly delete Safari cache-dir
  • */10 * * * * find /Users/<USERDIR>/Library/Safari -type f -exec rm {} \; 2>&1 > /dev/null
    */10 * * * * find /Users/<USERDIR>/Library/Caches/Metadata/Safari/ -type f -exec rm {} \; 2>&1 > /dev/null

And finally, I have created a wrapper .app file which open’s Safari, and then enables “Private Browsing” mode, as I could not find a way to do this through editing the Safari.plist file. I followed the instructions posted on the MacWorld site, and they go a little something list so:

  • 1. One needs to enable the Enable Access for Assistive Devices option, which can be found in the Universal Access system preference.
  • 2. Open the AppleScript editor, and type in the following commands :


    tell application "Safari"
       activate
    end tell
    tell application "System Events"
       tell process "Safari"
        tell menu bar 1
         tell menu bar item "Safari"
          tell menu "Safari"
           click menu item "Private Browsing"
          end tell
         end tell
        end tell
      end tell
    end tell

  • 3. Save this shiny new AppleScript as an application (.app file), and I called mine “PrivateSafari.app”.
  • 4. I then grabbed the icon file from Safari, and added to the PrivateSafari, and then replace the old shortcut in my Dock, with one to “PrivateSafari.app”.

It should be noted that I am well aware that the private browsing features in most of the modern web browsers have come under a certain amount of scrutiny recently, below are some links to articles for the interested reader :

One Response to “Private Browsing with Safari”

  1. RJ Says:

    Laudable, but an awful lot of effort for porn browsing :)
    Chrome in incognito mode does a good job.

Leave a Reply

By using this comment form you will have a cookie dropped in your browser, this is used to show the comment posted, which is awaiting moderation.