Speed up firefox with RAM cache and tmpfs in Linux

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/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.

speed up firefox linux about:config

  • 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 RAM, at least 4 GB in most cases, so moving the cache to RAM will not be a problem. But avoid this if you have less than 1 GB RAM.

  1. 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.
  2. Search for browser.cache.disk.enable  in the filter bar, toggle the value to false , this will disable cache to disk.
  3. 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.speed up firefox browser.cache.memory.capacityRight 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 .

finally 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 inheriently slow and disk I/O dependent. This process will make firefox blazing fast and disk I/O independent.

1. clear all cache and cookies

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.

3. mount the tmpfs on profile folder

add the line bellow to the /etc/fstab file,

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 for Ubuntu/Debian /Linux Mint etc.the script

cd /home/$USER/.mozilla/firefox/
if test -d *.default;then
if test -d profile.bac;then
rsync -a --delete *.default/ profile.bac/

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 minuite or whatever you like.

crontab -e

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.
Feel free to share this tutorial with your friends.

13 Responses

  1. Siddhartha says:

    Thank u so much for sharing this tricky job…very helpful

  2. Sajesh says:

    I followed your guide and there’s definitely some improvement. Thank you!

    One question: Will the tmpfs changes hold with Firefox updates? Do I need to do this again after the next update?

    • Arnab says:

      Thanks Sajesh for comment !
      You don’t need to worry about firefox update, all changes are hold on disk, inside the ~/.mozilla/firefox/profile.bac/ folder.

  3. mad slackw says:

    h11i ARNAB

    i’m experiencing some trouble with your tutorial regarding the backup of default profile data

    if you say :

    cp -a profile_name.default/ profile.bac

    and after that

    rm -rf profile_name.default/*

    what happens is that the profile_name.default is removed, right ? so when i try to mount the profile_name_default i see the message :

    /home/$USER/.mozilla/firefox/3x9htqj8.default does not exist

    and the subsequent steps fails, so right now i have a kind of a new firefox install everytime i reboot the laptop

    am i doing something wrong on this steps ?

    thanks in advance

    • Arnab says:


      Does the folder 3x9htqj8.default exists ?
      I tested the procedure again just before writing this comment, and it’s working with Firefox 45 .

      You may try to temporarily mount the profile folder, for testing purpose,

      sudo mount tmpfs -t tmpfs -o size=128M /home/$USER/.mozilla/firefox/3x9htqj8.default

      Hope this helps, and please don’t forget to notify me when you’re done.

  4. Michel says:

    Hi, almost works fine, except my when I want to copy my default.profile shows me a lot error messages :
    #cp -a k02hcabe.default.back k02hcabe.default
    I got these messages:
    cp: no se puede crear el fichero regular «k02hcabe.default/k02hcabe.default.back/sessions/backup-70.session»: Permiso denegado

    • Arnab says:

      What’s the language ? Spanish ? It seems like that you don’t have proper permission to create the folders/files.

      Try this cp -a k02hcabe.default k02hcabe.default.back

      And thanks for your feedback.

  5. Pablo says:

    This is an excellent idea! Is there a way of checking that the profile was successfully mounted to tmpfs? And a way of checking it’s synching properly?

    • Arnab says:

      Hi Pablo, good questions 🙂

      1. If the machine was shutdown, perhaps there is no way to check if the profile folder was mounted as tmpfs or not, unless you run some script to monitor that activity. But you can easily check if the folder is currently mounted by the mount command.

      2. You can check if the profile folder was synced properly or not by monitoring the crond logs, use this grep -i 'cron' /var/log/syslog

Leave a Reply

Your email address will not be published. Required fields are marked *