Moving your browser cache to a ramdrive
So, memory is dirt cheap right now. Crazy considering the prices just 2 years ago. I started with 8GB in my machine, then upped it to 16GB. The reality has been, sadly, that I haven’t really seen a speedup or perf improvement from that extra ram as I rarely seem to use over even 8gb of memory. Think my max has been 12GB so far. It’s not really wasted as Windows 7 Prefetch is populating it with programs in the background – but that’s not super- interesting now that I have an SSD drive. However, I do want to save my SSD from lots of browser cache writes. What if I told you that you could do that, speed up your browsing by about 20% AND keeping you more secure. How? By moving the browsers cache to a ramdrive.
- Speed – reports are anywhere from 20%-100% speedups
- Privacy – When you shut down and the ramdrive goes away – your entire browsing cache and cookies are irrevocably erased unless you persist/restore it from a regular drive. No tracking cookies or other nasty junk is left around. No need to ‘safe delete’ files.
- Security – I’ve also already seen where this method caught a pop-up virus because when I rebooted and the app tried to install itself during the bootup cycle, the payload that was in the cache was gone and I caught the installer’s error message.
- As long as you’re mostly hibernating/waking and not rebooting, the cache stays active and in memory.
- Free and automatic once set up with about 5 easy steps
- Some browsers are building this method into the browser itself
- If you want to persist the cache between reboots – you can with a simple checkbox select.
- Unless you persist/restore the ramdrive to a regular drive, you have to rebuild the cache each time you reboot. First browsing on a page requires the reload of all the data.
- Could potentially slow down your entire system if you are running short of memory
- Requires an initial setup
So, how do you do it? The detailed instructions are on the linked websites below, but I’ll summarize here in case those instructions go away. This is for firefox, but works for all other browsers too.
- Download DataRam Ramdisk and install it. Amazing little ramdrive program that works on x32 and x64 Windows systems all the way up and through Windows 7. Great GUI frontend, does everything you expect, super stable, restarts on boot automatically.
- Open the Ramdisk configuration utility after install:
- Select the Settings tab
- Set the size to anything from 500-1500mb
- Set the file system type to Fat32
- Check the Disk Label checkbox and make sure the drive name is ‘RAMDisk’
- Select the Load and Save tab (optional step if you want the cache to persist between boots)
- If you want the browser cache stored and reloaded when you shut down the machine, select ‘Save disk image on shutdown’ and ‘Load disk image on Startup’. Make sure they point to the same image file.
- I don’t do either of these as I want my cache to go away. Loading/Saving the state will also increase both your bootup and shutdown times.
- Select the Settings tab
- Open Firefox
- Type ‘about:config’ (no quotes) in the address bar
- Hit the ‘I’ll be careful’ button
- Right click – select New -> String
- Type ‘browser.cache.disk.parent_directory’ into the box and press OK
- Type the path of your BrowserCache directory using the drive letter of the Ramdrive i.e. ‘R:BrowserCache’
- Close all open Firefox tabs and windows
- Reopen Firefox, open any webpage, and see if there is a new directory called BrowserCache on your ramdrive.
- Fix the drive letter on reboot. Ramdisk has an annoying feature. On reboot, it’ll assign the Ramdrive whatever random drive letter is available. Obviously, this breaks the cache directory assignment in Firefox. You’d need to update Firefox each reboot to point to the right drive. Totally unacceptable. DataRam’s Ramdisk doesn’t allow you to specify the drive letter of the ramdisk. Totally unacceptable. But – you can get around this by having a script move the drive letter during bootup.
- Copy the below code, then use notepad or other text editor to save it in a file called C:RamdiskRename.bat
- Press Win + R (or find “Run” on start menu), a “Run” dialog will appear. Enter “gpedit.msc” and select the “gpedit” in Programs list.
- In the left pane, click “Local Computer Policy” -> “Windows Settings” -> “Scripts(Startup/Shutdown)” then on the right side, click “Startup”
- In the pop-up dialog, On the “Scripts” tab, click “Add…” and add the “C:RamdiskRename.bat” to the list. Click “OK” to finish.
Thats it! To test it, reboot your machine, and you should see the ramdisk always at R. When you open the browser for the first time after a reboot, you should see the cache directory appear in that drive. Using the Chromium benchmarking tool, the original author found that page load times were reduced by around 20%. Shutting down and restarting the browser is also a lot quicker.
:: Get ramdisk disk number in diskpart
echo list volume > %systemdrive%ListDrives.tmp
diskpart /s %systemdrive%ListDrives.tmp > %systemdrive%DriveList.tmp
FOR /F "tokens=2-4" %%a IN ('type %systemdrive%DriveList.tmp') DO @IF /I "%%c"=="%_ramdisklabel%" @set _ramdisknum=%%a
:: Create drive change script
echo. > %systemdrive%ChangeDrive.tmp
if DEFINED _ramdisknum (
echo select volume %_ramdisknum% >> %systemdrive%ChangeDrive.tmp
echo assign letter=%_ramdiskletter% >> %systemdrive%ChangeDrive.tmp
:: Run diskpart using the new script file
diskpart /s %systemdrive%ChangeDrive.tmp
:: Delete the script files
del /q /f %systemdrive%ListDrives.tmp
del /q /f %systemdrive%ChangeDrive.tmp
del /q /f %systemdrive%DriveList.tmp
exit /b 0
3 thoughts on “Moving your browser cache to a ramdrive”
Hi would you mind stating which blog platform you’re working with?
I’m planning to start my own blog soon but I’m having a difficult time selecting between
BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design seems different then most blogs and I’m looking for something completely
unique. P.S Apologies for getting off-topic but I had to ask!
I’m using WordPress – but this theme is one that I modified and wrote up myself. I don’t even think of it as complete as I have a few problems with it and unfinished bits.
I found WordPress to be the easiest to use so far, but I only do this in my spare time so I wouldn’t say I’m an expert. Let me know if that helps.
Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my
blog that automatically tweet my newest twitter updates. I’ve been looking for a plug-in like
this for quite some time and was hoping maybe you would have some experience with
something like this. Please let me know if you run into anything.
I truly enjoy reading your blog and I look forward to
your new updates.