To anwer your question because so far all the answers are too complicated, and not really efficient, the best way to force Firefox to cache on memory is going to about:config, find browser.cache.disk.enable and set it to false, and that’s it, from now on Firefox will use memory to store website cache
2 Likes