To enhance Firefox performance on Ubuntu (or Linux), we can place the cache in RAM. This is especially helpful if you are used to hours of continuous browsing sessions.
I have mounted some directories with temporary files using the tmpfs, which is RAM based filesystem. These files will be discarded at reboot, which also helps to keep my system clean.
The entries in /etc/fstab are like:
tmpfs /tmp tmpfs noexec,defaults,noatime,nodiratime 0 0
tmpfs /var/log tmpfs noexec,defaults,noatime,nodiratime 0 0
Add the following line at the end of /etc/sysctl.conf file:
vm.swappiness = 0
# sudo sysctl -p
In Firefox, go to about:config page and search for the following entry:
If it is not there, right click and create a new String value and name it as
Set the value to /tmp (or tmpfs directory of your choice). Restart Firefox.