For the last few months, Safari would forget bits of my browsing history every time I closed it. After around 24 hours only one or two items would be left listed for the previous day of browsing. There was no logic to what was being remembered or how quickly history items would disappear.
I upgraded OS X; I disabled all my Safari extensions; I cleared out the cache, cookies, and the few items left in History; I turned off syncing Safari to iCloud in System Preferences; I closed every application and background process I found running; I checked to make sure that “remove history items” wasn’t set to “after one day”1 and I even changed it to “manually” to see if there was a bug. Nothing worked.
If you’re here it probably means googling hasn’t been helpful: most search results are for people who want to disable history tracking. I feel your pain, but hopefully you’re in luck.
My problem stemmed from a corrupted database in
~/Library/Safari/. There are four or five files in that folder related to storing your history, depending on your OS version. You should close Safari and then delete all of them:
HistoryIndex.sk (if it exists).2
With any luck, you should now be able to open Safari, load a website, and then close Safari without it losing your history.
- Screenshots and instructions updated for macOS 10.15 (Catalina), although I haven’t needed to do this again since publishing the article. — 31 May 2020