I wanted to save a local copy of an image on a webpage I was viewing in the Google Chrome browser on a Windows 10 system, but I couldn't right-click on it to download it, so I thought I could look for it in the Chrome browser cache, which is located at
C:\Users\username\AppData\Local\Google\Chrome\User
Data\Default\Cache
where username is the name of the relevant
account on a Windows system. I had the
ChromeCacheView
program from NirSoft on the
system, which provides a command-line option to copy image files from the
Chrome cache for a user, so I used it. Since I was logged into a regular
user account, I
opened a command prompt as the
administrator and then made the working directory the directory where
the ChromeCacheView program was located with
cd C:\Program Files (x86)\Network\NirSoft\ChromeCacheView
. Then
from that directory I issued the command below:
chromecacheview -folder "C:\Users\JohnDoe\AppData\Local\Google\Chrome\User Data\Default\Cache\" /copycache "" "image/png" /CopyFilesFolder "c:\users\johndoe\documents\temp\chrome" /UseWebSiteDirStructure 0
You can use the -folder
option to tell ChromeCacheView which
user's cache file you wish to use while the /copycache
option
can be used to specify the directory where you want images, such as
PNG files,
to be copied—in this case I was looking for a .png file because when I
examined the HTML code on the
webpage I thought that the the image was a PNG file. I created a
temp\chrome
directory under the Documents directory for
the user account prior to issuing the command to hold the images stored
in the cache. After the command completed, I could see all of the PNG
files that had been in the Chrome cache in that temporary directory I
had created.
When I didn't see the image I was looking for, I thought I might have misidentified it in the code, so I copied all of the image files from the cache directory, not just the PNG ones by changing "image/png" to "image" in the command. I.e.:
chromecacheview -folder "C:\Users\JohnDoe\AppData\Local\Google\Chrome\User Data\Default\Cache\" /copycache "" "image" /CopyFilesFolder "c:\users\johndoe\documents\temp\chrome" /UseWebSiteDirStructure 0
That copied AVIF (.avif), BMP GIF (.gif), icon (.ico), JPEG (.jpg), JPEG File Interchange Format (JFIF) (.jfif), SVG (.svg), and WebP (.webp) files from the cache as well as the PNG ones.