Limit Firefox Cache

Just an FYI post.

In all previous slacko versions I did not bother limiting the browser cache. The only way I knew how to do it was to install a default profile in /root/.mozilla. If you decide to run the browser as spot then this totally defeats the purpose.

Mozilla in their infinite wisdom has decided to remove that option from it’s gui preferences program. Rolling Eyes . The only way to do it now is manually through about:config.

With a bit of research I devised a way to limit the browser cache without installing a default profile.

A file; /usr/lib/firefox*/defaults/preferences/local-settings.js needs to be created (you can check it out at /usr/lib/firefox-17.0.11/defaults/preferences). It contains the following:

Code:
//
//default home page and cache
pref(“browser.startup.homepage”, “data:text/plain,browser.startup.homepage=file:///usr/share/doc/home.htm”);
pref(“browser.cache.disk.capacity”, 60000);

You’ll notice that this also sets the home page.

The trick about this though was how to implement it without hard coding?

Well I did this at the woof level with a pinstall.sh. The relevant part of the pinstall.sh contains this:

Code:
# work around for firefox bug to set cache
if [ `pwd` != ‘/’ ];then
FF=$(find usr/lib -type d -name firefox*)
PKGSTATDIR=`find ../../ -type d -name status -maxdepth 3`
PKGSTATFILE=`find $PKGSTATDIR -type f -name ‘findpkgs_FINAL_PKGS*’`
FFVER=`grep ‘firefox’ $PKGSTATFILE | awk -F’|’ ‘{print $6}’`
FFVER=${FFVER%%.*}
if [ “$FFVER” -ge 21 ];then
mkdir -p ${FF}/browser/defaults/preferences
PREFDIR=”${FF}/browser/defaults/preferences”
else
mkdir -p ${FF}/defaults/preferences
PREFDIR=”${FF}/defaults/preferences”
fi
cat > ${PREFDIR}/local-settings.js <<_EOF
//
//default home page and cache
pref(“browser.startup.homepage”, “data:text/plain,browser.startup.homepage=file:///usr/share/doc/home.htm”);
pref(“browser.cache.disk.capacity”, 60000);
_EOF

fi

That will seem like jumble to some, but all it does is create the above file. One important note though; mozilla, again in their infinite wisdom, moved the location of where these type of files are read in firefox-21. From /usr/lib/firefox*/defaults/preferences to /usr/lib/firefox*/browser/defaults/preferences.

This should work for seamonkey as well but the version change over would have to be noted.

Many thanks to Mike’s Musings.

Advertisements

One thought on “Limit Firefox Cache

  1. In Firefox 36 (most recent) and earlier versions you can limit cache under Edit, Preferences, Advanced, Network – check the Override Automatic Cache Management and enter a value (I set mine to 20MB)

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s