Some days ago I have written a post about How speed up Firefox by storing its cache files in RAM instead of in the disk.

However, there is always a downside and in this case it is that once you shut your computer off, you loose all your day cache.

This means, that the next time you turn your computer on, you will have to download again all icons, .js, .css files that maybe have not expired yet.

The solution for this I have started to use, is to copy all the cache folder to the disk when turning off my PC, and copy it back again to RAM when I turn on the computer again. I have created one script to poweroff the computer.

Let’s name it turn-off.sh

Here is the listing:

#!/bin/bash
rm -rf /home/user/cache-firefox/*
mv /dev/shm/* /home/user/cache-firefox/
poweroff

Be sure to change user by your own user, save it in your home directory, make it executable

sudo chmod +x /home/user/turn-off.sh

and when you want to turn the computer off, simply run:

sudo /home/user/turn-off.sh

We are done with the poweroff routine.

To copy all the files back to the RAM when the computer is turned on. Modify the /etc/rc.local

If you know a better way, please let me know about it.

Here is the listing of my rc.local file.

#!/bin/bash
#
# /etc/rc.local: Local multi-user startup script.
#
mv /home/user/cache-firefox/* /dev/shm/

Update 10.08.10: A friend of the blog, has a very good suggestion. “I would put the FF cache in a subdirectory of /dev/shm, you may have other applications running which use a large amount of shared memory and doing it like this would copy it all to that /home/user/cache-firefox directory which is probably not what you want. “

To do this, you need to create that directory on rc.local, each time the system boot, and also tell Firefox to use that folder to store the cache.