Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'View Safari cache files while offline' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
View Safari cache files while offline
Authored by: tehthehteh on Nov 28, '11 04:31:34PM
Thanks for the tip! MesaSQLite looks great.

I put together this quick hacked shell script below, which gives you an overview of all images in the cache. It extracts the images from the cache, puts together a temporary HTML file on the desktop, opens the page in Safari and deletes it once loaded.
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"" > ~/Desktop/cache.html
echo "    \"\">" >> ~/Desktop/cache.html
echo "<html lang=\"en\">" >> ~/Desktop/cache.html
echo "  <head>" >> ~/Desktop/cache.html
echo "    <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">" >> ~/Desktop/cache.html
echo "    <title>Cached Images</title>" >> ~/Desktop/cache.html
echo "  </head>" >> ~/Desktop/cache.html
echo "  <body>" >> ~/Desktop/cache.html
sqlite3 ~/Library/Caches/ "SELECT request_key, time_stamp FROM cfurl_cache_response WHERE request_key LIKE '%.jpg' OR request_key LIKE '%.jpeg' OR request_key LIKE '%.gif' OR request_key LIKE '%.png' ORDER BY time_stamp DESC;" | perl -ne 'chomp; ($url, $time) = split(/\|/); print "<a href=\"$url\"><img src=\"$url\" alt=\"Downloaded at $time\"></a> <a href=\"$url\">$url</a> $time<br>\n";' >> ~/Desktop/cache.html
echo "  </body>" >> ~/Desktop/cache.html
echo "</html>" >> ~/Desktop/cache.html
open -a Safari ~/Desktop/cache.html
sleep 1
rm ~/Desktop/cache.html
Open up Terminal, type "nano cache", paste in this script, save using 'Ctrl-X' and then 'Y'. Run "chmod +x cache" to make it executable. Now, anytime you want to bring up all cached images, you can open up Terminal, type 'cache' and woo! Images! It also keeps the URLs, in case you want to search for a file name. A word of warning though: there might be a lot of images in there.

[ Reply to This | # ]