Firefox, the second most popular web browser, the default pre installed browser in many GNU/Linux distributions. It is really great in terms of it's customization capability and large collection of add-ons.
Though many users find firefox frustratingly slow and sluggish, so they switch to other browsers like Google Chrome or Chromium etc. There are many reasons for it's sluggish performance, like storing cache to disk, using slow sqlite databases, frequent disk access by other processes, no DNS cache and like so many of them.
But there are many of ways to make it faster and improve page load time. In this tutorial we are going to do this by modifying the firefox about:config configurations, moving all profile data to a tmpfs partition on RAM and moving the cache to RAM instead of hard disk. This guide will work all GNU/Linux Distributions like Ubuntu, Fedora, Debian, Arch Linux etc. etc.
Optimize the about:config configurations
Open up firefox, type about:config in the URL bar , hit Enter and press the I’ll be careful, I promise! button, now you can edit the configurations. Use the search bar to find configurations easily.
- Search for browser.cache.use_new_backend , if the value is 0 , modify it to 1 , this makes the caching efficient.
- Search for network.http.pipelining.ssl toggle it value to true .
- Search for network.http.pipelining , toggle the value to true .
- Search for network.http.proxy.pipelining , toggle its value to true .
- Search for network.http.pipelining.maxrequests , modify the value , set any thing above 100 , like 120 .
- If you are not using IPv6, then search for network.dns.disableIPv6 and toggle its value to true .
- Search for browser.safebrowsing.enabled and browser.safebrowsing.malware.enabled , toggle the value to false, in both of them, though this is a little bit dangerous.
Move the cache to RAM
As RAM is much much more faster than hard disk, so moving cache to RAM will increase the user experience greatly. Recent computers have plenty of free RAM, so moving the cache to RAM will not be a problem. But avoid this if you have less than 1 GB RAM.
- Again, open up firefox and type about:config in the URL bar, hit Enter and press the I’ll be careful, I promise! button. Now edit few thing in this section.
- Search for browser.cache.disk.enable in the filter bar, toggle the value to false , this will disable cache to disk.
- Now it is the time to enable cache to RAM, search for browser.cache.memory.enable , if the value is true leave it else toggle it to true.Now assign how much memory could be used as RAM cache, search for browser.cache.memory.capacity , if not found create it.Right click on blank area, then select "New" > "Integer" , set the preference name browser.cache.memory.capacity , enter the integer value in KB, like 204800 for 200 MB , and done . Check it with about:cache .
Move profile data to a tmpfs partition
Finally move all profile data to a tmpfs partition on RAM , tmpfs is a incredibly fast special type of file system that uses a part of RAM to store data. Firefox stores almost every information in SQLite databases, but SQLite is inherently slow and disk I/O dependent. This process will make Firefox blazing fast and disk I/O independent.
Perhaps you know how to do that, if not, click Edit > Preferances go to Privacy and clear cookies, then go to Advanced > Network clear Cached Web Content and done !
2. backup default profile data
Create a backup archive of your current data, before doing this close Firefox and look at the commands bellow.
cd .mozilla/firefox/ cp -a profile_name.default/ profile.bac rm -rf profile_name.default/*
must replace profile folder name with your own profile folder name. This will create a folder named profile.bac containing all profile data and clear all data inside the default profile folder.
Enjoy free shipping and One-Day delivery, cancel any time.
3. mount the tmpfs on profile folder
Add the line bellow to the
tmpfs /home/$USER/.mozilla/firefox/profile_name.default tmpfs size=128M,user,exec,uid=1000,gid=1000 0 0
My firefox default profile name was p3iyxcse.default , so the line at
/etc/fstab looks like bellow.
tmpfs /home/b00m/.mozilla/firefox/p3iyxcse.default tmpfs size=128M,user,exec,uid=1000,gid=1000 0 0
Make sure that the
/home/$USER/.mozilla/firefox/profile_name.default directory exists, otherwise tmpfs mounting will fail .
Now mount the tmpfs at profile directory , i.e. at
/home/$USER/.mozilla/firefox/profile_name.default and copy all the backup data to the default profile folder.
sudo mount -a cd .mozilla/firefox/ cp -a profile.bac/* profile_name.default/
Do not forget to replace profile_name.default with your own profile name. And now start Firefox, if you have a slow HDD like me, then you will notice a much faster start up time and no sluggish performance .
4. sync any changes to the profile folder with the backup folder
In order to keep the changes intact after a reboot or shutdown, we need to sync the profile folder with the backup folder time to time.
To do this without any user interaction in later, save the script bellow as ff_profile_sync and add it to crontab . Before doing this if you do not have rsync , run
sudo apt-get install rsync on Ubuntu, Debian or Linux Mint etc. the script is below.
#!/bin/sh cd /home/$USER/.mozilla/firefox/ if test -d *.default;then if test -d profile.bac;then rsync -a --delete *.default/ profile.bac/ fi;fi
Do not forget to replace $USER with your username, save this script at
/usr/local/bin or wherever you like, make it executable, and add to crontab with
crontab -e , set the cron interval 5-10 minute or whatever you like.
Put the line bellow for a 5 minuite update interval .
*/5 * * * * /usr/local/bin/ff_profile_sync > /dev/null 2>&1
Finally add the line bellow to the
/etc/rc.local file just before the exit 0 , to restore the previous changes after a reboot .
cp -a /home/$USER/.mozilla/firefox/profile.bac/* /home/$USER/.mozilla/firefox/profile_name.default/
Again, Do not forget to replace $USER with your username and profile_name with your firefox profile name.
This setup will backup all changed profle data to the profile.bac folder automatically, so forgot about it , and enjoy super fast firefox.
If you have any question or need further assistance just leave a comment, we’d be happy to assist you.
Also feel free to share this tutorial with your friends.