How to set Firefox Cache Location

I wrote this because I dislike the default cache location in Firefox, and Firefox doesn't provide a simple menu-driven method to change it. I'm sure there must be other people out there who've wanted to change the cache location, but were puzzled by the lack of any option to do that in the Firefox menu.

Applies To

Any version of Firefox over and including Firefox 2.0 (also works with Firefox 3.5) on Windows XP.

Subject

How to change the default cache location in the Firefox web browser.

Purpose

I do it because the default location for the Firefox cache in Windows XP is:

C:\Documents and Settings\<username>\Local Settings\
Mozilla\Firefox\Profiles\<profile ID>\Cache

This, in my opinion, is a terrible location for a browser cache. A browser cache is one of the fastest-changing directories on the drive. Every time you load a web page, the contents of the browser cache get overwritten and modified. This is a scene of very high file input/output activity.

File activity causes fragmentation, which eventually slows down access to files on the hard drive. This slows down the computer. I would least like to have fragmentation on the drive which contains my operating system and programs, and since the operating system is usually on the C: drive, this is a nasty place for a browser cache. Also, some people partition their drives so they have limited space on the operating system or program partitions. Optimally, you'd want a large browser cache, but you may not have space on the operating system drive for a large cache.

If you are one of them, read on. Or you can skip my random musings and jump directly to the procedure.

I personally partition my hard drive(s) in the following manner:

The advantages of this scheme are (1) organization, (2) some separation between data and applications and OS, and (3) lower fragmentation. I run Diskeeper to defragment my drives. If you do not have Diskeeper, Windows has a built-in defragmentation tool which you can use. If all else fails, since browser caches are on a completely separate partition, you can simply clear the cache from within all your browsers and start afresh. There are no other files on this partition, so clearing the caches pretty much cleans up the disk.

How to Change Cache Size and Location in Firefox

1. Start Firefox. Click on Tools in the main menu, choose Options. A dialog window will open up, containing several tabs. Click the Advanced tab. Several sub-tabs will open up below it. Click on the Network tab, and under the heading Offline Storage find the button marked Clear Now. Click this button to clear the cache. This will delete all files that are currently cached (on drive C: in the default location decribed above). Now that the old cache is gone, you can tell Firefox to choose a different cache location.

2. Start Windows Explorer, if you don't already have it open. Go to the drive where you want to create the new cache. Create a directory there that will hold the cache. For example, I wanted to set the new cache location to my drive T:, so in Windows Explorer, I created the directory T:\Firefox 3.5 Cache\. You can pick whatever drive and directory you want for the cache, but create it first before changing cache location in Firefox just to avoid any problems.

3. Now to tell Firefox to use the new cache directory you have created. In Firefox, open a new tab, and in the address bar, type about:config and press Enter. You will get a warning that you're about to mess with stuff under the hood, click OK to move on. Now you'll see a list of Firefox configuration settings, with one setting on each line.

4. The list of configuration settings is alphabetically arranged, so scroll down to the b's and see if you can find a setting named:

browser.cache.disk.parent_directory

You will probably not find it, unless you have set it up before. Fresh copies of Firefox do not come with this setting, so unless you or someone actually created this setting, it shouldn't be there.

5. Right-click anywhere in the window, to see the right-click menu. In this menu, choose New and then String. A box will appear, prompting for "Enter the preference name". In this box, type browser.cache.disk.parent_directory and click OK. The box will now ask for the value of this setting. For the value, type in the complete path to the new Firefox cache directory you created in step 2 above. For example, in my case, I typed in "T:\Firefox 3.5 Cache\" (without the quotes). Click OK, and the new cache location will be set.

6. You will now see a new value in the configuration (you may have to hit the refresh button to see it). This will show you the new cache location you just set.

You can modify the cache size here too, if you wish. Just highlight "browser.cache.disk.capacity" and right click and choose Modify in the right-click menu. It will ask you to enter a new value. Remember, Firefox measures in units of kilobytes, so in the screen capture above, my setting of 1048576 represents 1 GB (1024 x 1024 kilobytes).

7. Restart Firefox. Now Firefox will start using your new cache. That's all there is to it!

 

On a related note, here's what you can do to change the cache location in Google Chrome.