From the Terrible Solutions to Terrible Problems Dep't:
I deleted a file on a web server. It was a CSS file, a file I wanted, a file that makes things right, that is hard to recreate without a backup. A file I hadn't backed up because I just created it today.
But I've been here before, loosely. I've done a lot of horrible things to recover files. I've saved scrollback buffers as UTF-16 and converted them back to ASCII using iconv. I've dismounted filesystems and done string analysis on their raw block devices. I've even dumped memory. And, I thought to myself, I've retrieved files from browser caches.
Fortunately, I've been testing this site change in Safari recently, so I knew it would be cached. Safari used to use a file-based cache, and it was trivial to recover a file: pretty much you just go into a directory and look at a bunch of files with UUIDs for names, then grep the ones that look about the right size. But Safari uses SQLite as a cache now.
Here's the SQLite magic for recovering the file to stdout:
sh$ cd ~/Library/Caches/com.apple.Safari
sh$ echo "select receiver_data from cfurl_cache_receiver_data where entry_ID = (select entry_ID from cfurl_cache_response where request_key like '%filebrowser.css%');" | sqlite3 Cache.db >~/filebrowser.css
filebrowser.css was part of the URL I needed to retrieve. request_key stores URLs, exactly.