Firefox Cache outside $HOME

Jurjen Bokma

April 2013


Having the Firefox cache in $HOME slows Firefox down when $HOME is on a network, e.g. over NFS. This article documents moving Firefox' cache out of $HOME.

Our users have their homedirs on an NFS server. Firefox is slower than it should be because its cache is on NFS.

This can be fixed by putting in /usr/lib/firefox/defaults/pref/all-MyCompany.js:

// works:

pref("general.config.obscure_value", 0);
pref("general.config.filename", "MyCompany.cfg");

... and in /usr/lib/firefox/MyCompany.cfg:

var env_user = getenv("USERNAME");

var env_home = getenv("HOME");
var env_mozdebug= getenv("MOZILLA_DEBUG");

// find the path to the profile directory
var profhome = Components.classes[";1"].getService(Components.interfaces.nsIProperties).get("ProfD",Components.interfaces.nsIFile).path;

// work out the profile salt+name
var profname=profhome.match(/[^\/]+$/);

// this matches what our hack wrapper symlinked the Cache into...
var cache_dir = "/tmp/MozillaFirefox-" + env_user + profname;
defaultPref('browser.cache.disk.parent_directory', cache_dir);
defaultPref('browser.cache.offline.parent_directory', cache_dir);

if (env_mozdebug) {
    displayError("debug ffox cfg v100",
                 "\n\nuser=" + env_user +
                 "\nhome=" + env_home +
                 "\n\nprofile-path="+profhome +


The ratio between correct and outdated, beside-the-point, or just plain wrong information I could google up on this topic was particularly poor.