How to save a file from the Chrome or Firefox file store cache

There’s a couple of ways to recover a file from the Chrome/Firefox cache – the most straightforward option is the CacheViewer add-on for Firefox and ChromeCacheView for Chrome (Windows only). But sometimes you need to roll up your sleeves and tinker with about:cache.

Once you’ve found the file you want to save, you’ll be confronted with a hex display like this:

Chrome and Firefox about:cache display

So what now? Unhelpfully, the browser won’t save the file. Copy the hex part (outlined in red above) into a new text file (call it “input.txt”) and run this python script

import os,sys
f = open(os.path.dirname(sys.argv[0]) + “input.txt”,”r”)
hex = “”
for line in f:
     line = line[11:73]
     print line
          for c in line:
          if c != ” “:
               hex += c
f.close()
c2 = None
output = “”
for c in hex:
     if c2 == None:
          c2 = c
     else:
          x = eval(“int(0x” + c2 + c + “)”)
          output += chr(x)
          c2 = None
f = open(os.path.dirname(sys.argv[0]) + “output.txt”, ‘w’)
f.write(output)
f.close()

The script will convert your input file and write “output.txt” which will be your rehydrated file. Rename “output.txt” to the files original name, and you’re done.