Here are the steps:
- Type about:config into the address bar
- Type browser.cache into the Filter field
- Set browser.cache.disk.enable to false (double click it)
- Set browser.cache.memory.enable to true (double click it)
- Right click > New > Integer; type browser.cache.memory.capacity; press OK
- Type in 100000 (this is equivalent to 100 megabytes); press OK
- Close all Firefox tabs and windows, and then restart the browser
You may try using 500000 for 500 MB of cache, or -1 to tell Firefox to dynamically determine the cache size depending on how much RAM you have.