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["@mozilla.org/file/directory_service;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 + "\nprofile-name="+profname ); }
Yes, that MyCompany.cfg has to go in /usr/lib/firefox. I know of no way to change its location. Neither does Mike.
Part of the Preferences API mentioned at MIT also works in all-MyCompany.js. But e.g. 'env' seems not to exist there. So you really do need to create that MyCompany.cfg.
I tried to run the javascript on Rhino outside Firefox, but found that rather useless.
This Cambridge doc originally got me on the right track.
There is some documentation at mozilla.org (but also reap URLs from the bug it mentions) and mozillazine.org, but it isn't all up-to-date. (Same with the MIT docs, btw.)
Note | |
---|---|
The ratio between correct and outdated, beside-the-point, or just plain wrong information I could google up on this topic was particularly poor. |