These are some speed hacks for browsers by moving the cache from the disk to a tmpfs mount point. This hack is not recommended for machines that don't have enough installed memory. These scripts are developed with Ubuntu in mind, therefore they may need adaptation for specific distributions.
Although it may greatly improve the browser responsiveness with slower hard drives, it adds quite a lot of overhead to the cold start-up time. Subsequent launches are fast since all the cache is preloaded in the tmpfs drive.
Firefox needs to change the location of the disk cache in order to achieve this goal. Go to about:config and change this value: browser.cache.disk.parent_directory
to /dev/shm/firefox-$USER/ where $USER is the output of id -nu
in your user terminal. If browser.cache.disk.parent_directory
does not exist, add it as a new String value.
The Google Chrome launcher works out of the box. The cache is limited to 512 MiB. If you need more cache, change the hard-coded value from the chrome-launcher script.
It is recommended to change the swappiness value to 0 in order to keep the tmpfs in memory instead of sending it to the swap. A tmpfs is not guaranteed to live entirely in the memory, therefore the swappiness value may improve the latency.