[SOLVED] Force Folder "mozilla-temp-files" to a Ramdisk?

User Help for Mozilla Firefox
User avatar
BuddhaNature
Posts: 537
Joined: January 3rd, 2008, 9:44 am
Location: Scotland

[SOLVED] Force Folder "mozilla-temp-files" to a Ramdisk?

Post by BuddhaNature »

Hi,

I have Firefox setup to create its cache files into a folder on a ramdisk using the following setting:

browser.cache.disk.parent_directory (which can be set via about:config)

Once I did that I thought all Firefox temporary files would be written to the ramdisk. Unfortunately this isn't the case. There is still a folder and its content files that get written into the "Temp" folder on my system. The folder is "mozilla-temp-files". Does anyone know if there is a setting that can be made in Firefox to force this folder and its contents to be created in my ramdisk (not in the Temp folder on the HDD)?
Last edited by BuddhaNature on August 1st, 2015, 3:57 am, edited 1 time in total.
OS: Windows 10 Pro. x64
User avatar
therube
Posts: 21714
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Re: Possible to Force Folder "mozilla-temp-files" to a Ramdi

Post by therube »

Use a batch file to start FF?

Something like:

Code: Select all

set   TMP=X:\RAMDISK\TMP
set  TEMP=X:\RAMDISK\TMP
C:\Program Files\Firefox\Firefox.exe
exit


Likewise, keep an eye out for .part files.
(Looks like they go into the same location, so should be handled too.)
Fire 750, bring back 250.
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball CopyURL+ FetchTextURL FlashGot NoScript
User avatar
BuddhaNature
Posts: 537
Joined: January 3rd, 2008, 9:44 am
Location: Scotland

Re: Possible to Force Folder "mozilla-temp-files" to a Ramdi

Post by BuddhaNature »

Well yes therube, I see where that is at but I think the problem with it is that it sets those paths for all files that are written into TMP/TEMP after the batch has been used - not just for files created by Firefox. The problem with that is that sometimes files are written into the TMP/TEMP folders that will be needed after a system reboot. It the entire TMP/TEMP folders are moved to the ramdisk then on a reboot the contents entirely vanish so programs that put files there to be used on a reboot can't access the, now disappeared, files.

I was really hoping for a way to just deal with getting the Firefox files into the ramdisk.

It's interesting, when I visit various forums there seem to be an increasing number of people asking for greater control over where temporary files are being placed because they have SSD rigs. They don't want the temporary files being written to SSD because it reduces the life-span of the SSD. They want the control to get the temporary files written to HDD or to ramdisks. Something that Mozilla need to have a good think about by the looks of things - more and more people over time are going to want a lot more control over where temporary files are being written to. Mozilla should try to be ahead of that curve and be introducing the capability now.

I'm really surprised that there isn't already an easy way to get "mozilla-temp-files" written to a location of the user's own choosing.

Thanks for the response anyway, much appreciated.
OS: Windows 10 Pro. x64
vsub
Posts: 733
Joined: October 2nd, 2009, 2:20 pm

Re: Possible to Force Folder "mozilla-temp-files" to a Ramdi

Post by vsub »

Those mozilla-temp-files are created when you watch some video.
I also use ram disk but in my case,I'm forcing everything to use the ram disk when it wants to write to the temp folder.

The windows temp folder is set to my ram drive(I use SoftPerfect RAM Disk)and every program which is trying to write to the temp folder is writing there)...2gb of my 16gb ram is more than enough for me to save random thing that I may not need)
At windows startup the firefox profile is copied to the ram drive and I launch the profile by using a command line(I don't care about browsing history so when I turn off my pc,the firefox profile is deleted...and copied again at windows startup from the default location where everything is configured the way I want it)

And btw why not just disable the disk cache rather than making firefox write the cache somewhere(I don't use disk cache,everything is saved in ram(not the ram drive))
User avatar
BuddhaNature
Posts: 537
Joined: January 3rd, 2008, 9:44 am
Location: Scotland

Re: Possible to Force Folder "mozilla-temp-files" to a Ramdi

Post by BuddhaNature »

Okay, vsub. I use the same ramdisk software and it's free at that!

I do take the point about just changing the TEMP/TMP paths to the ramdisk but again there is a risk that on some occasions there will actually be file written to TEMP/TMP that needs to availible on reboot (and with a ramdisk that isn't going to happen unless your imaging the disk on system shutdown which defeats the purpose I'm trying to achieve).

Have to be honest and say that I don't understand what you're talking about when you mention copying your Firefox profile. What is that, how do you do that?

How do I disable the disk cache. What is setting, where do I alter it? (Disabling sounds like a great idea to me.)
OS: Windows 10 Pro. x64
vsub
Posts: 733
Joined: October 2nd, 2009, 2:20 pm

Re: Possible to Force Folder "mozilla-temp-files" to a Ramdi

Post by vsub »

Disabling the disk cache(this doesn't include mozilla-temp-files(there is no way to make ff not make them)
In the address bar type about:config and hit enter.If there is a button bellow,click on it
In the search field below,search for browser.cache.disk.enable and double click on it to make it false...ff will not save cache on the ssd\ram drive anymore(closing the browser will delete the cache which is saved in the system ram)

About copying the profile
From fiirefox=>Help=>Troubleshooting Information=>Show Folder it will show you your profile
Go back to the Firefox folder(look at the address bar)when you open your profile folder and open the file profiles.ini

Code: Select all

[General]
StartWithLastProfile=1

[Profile0]
Name=default
IsRelative=0
Path=X:\l0h7s1yw.default


My profile folder name is l0h7s1yw.default
Edit the file and save(while firefox is not running)and then copy the profile folder to your ram drive.
This way firefox will start even faster since ram is faster than ssd

If you do it correctly,when you try to start firefox from your shortcut,it will load the profile from the ram drive
User avatar
BuddhaNature
Posts: 537
Joined: January 3rd, 2008, 9:44 am
Location: Scotland

Re: Possible to Force Folder "mozilla-temp-files" to a Ramdi

Post by BuddhaNature »

Okay, vsub. Just to clarify.

The path you have "X:\10h7s1yw.default" is where "X:\" is your ramdisk? Is that correct?

So for use afterwards, after I've altered the "profiles.ini" file, I just need to write a script to copy my "odj8wnq7.default" folder to the ramdisk before I launch Firefox. Is that correct?

Oh, and if at any time I actually alter my profile then I need to remember to copy the newly altered profile back to HDD/SSD before I shut down the system and lose the contents of the ramdisk? Also just had a look at the "extension.ini" file in my "odj8wnq7.default" profile and from what is contained in that ini it looks like I would have to copy the "odj8wnq7.default" folder from ramdisk to HDD/SSD if update or make changes to any extensions that I have installed - is that correct too?
Last edited by BuddhaNature on July 28th, 2015, 10:39 am, edited 1 time in total.
OS: Windows 10 Pro. x64
vsub
Posts: 733
Joined: October 2nd, 2009, 2:20 pm

Re: Possible to Force Folder "mozilla-temp-files" to a Ramdi

Post by vsub »

BuddhaNature wrote:The path you have "X:\10h7s1yw.default" is where "X:\" is your ramdisk? Is that correct?

Yes X:\ is my ram drive letter
BuddhaNature wrote:So for use afterwards, after I've altered the "profiles.ini" file, I just need to write a script to copy my "xxxxxxxx.default" folder to the ramdisk before I launch Firefox. Is that correct?

If you call "before" the first time you start firefox,then yes.If you mean before every firefox start,then no(sometimes firefox may not start if you do that and you may have other problems)
Do it just once at windows start(I place my autohotkey script in the startup folder in the start menu)

BuddhaNature wrote:Oh, and if at any time I actually alter my profile then I need to rememeber to copy the newly altered profile back to HDD/SSD before I shut down the system and lose the contents of the ramdisk?

Well I almost never do that but if you want some change to be saved,you have to either start the original profile and do the change or copy the profile from the ram drive to the ssd but I prefer the first one

To run the profile from the ssd after you edited the profiles.ini file to load the profiles from the ram drive,you can just use this shortcut
"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -profile "the path to your profile on the ssd"

But make sure ff is already closed before using the shortcut
User avatar
BuddhaNature
Posts: 537
Joined: January 3rd, 2008, 9:44 am
Location: Scotland

Re: Possible to Force Folder "mozilla-temp-files" to a Ramdi

Post by BuddhaNature »

Okay vsub. Thanks very much for the tips, what you're talking about is beginning to gell with me a bit now.

Basically if I make changes to my profile and/or to the extensions I have installed then on that one-time basis use the profile as it stands on HDD/SSD, make the changes, close Firefox - then go back to copying the (now altered) profile folder to the ramdisk.

Many thanks, much appreciated. =D>

All I need now is a solution to my original question at the start of this thread. #-o
OS: Windows 10 Pro. x64
vsub
Posts: 733
Joined: October 2nd, 2009, 2:20 pm

Re: Possible to Force Folder "mozilla-temp-files" to a Ramdi

Post by vsub »

Yes.
You can do whatever you want to your profile on the ram drive(install new things,change settings and so on)and when you think you want that change on the clean profile,just start it and make the change.
I do all kind of things on my ram drive profile because I know the next time I start my pc,everything will be like before.
User avatar
BuddhaNature
Posts: 537
Joined: January 3rd, 2008, 9:44 am
Location: Scotland

Re: Possible to Force Folder "mozilla-temp-files" to a Ramdi

Post by BuddhaNature »

vsub wrote:Disabling the disk cache(this doesn't include mozilla-temp-files(there is no way to make ff not make them)
In the address bar type about:config and hit enter.If there is a button bellow,click on it
In the search field below,search for browser.cache.disk.enable and double click on it to make it false...ff will not save cache on the ssd\ram drive anymore(closing the browser will delete the cache which is saved in the system ram)


Relevant to the browser.cache.disk.enable setting I just found the following setting that can be added in about:config to restrict the amount of memory that the cache in memory would use. The new setting is titled browser.cache.memory.capacity

Instructions on how to make the setting can be found here: http://thetechjournal.com/how-to/tutorial-how-to-move-your-mozilla-firefox-cache-memory.xhtml

It is interesting though that there is a difference over what is said about this setting and what vsub was saying about when that cache in memory would be cleared.
vsub wrote:(closing the browser will delete the cache which is saved in the system ram)


However, the instructions at the link above say that the cache would only be cleared on a system restart. I'm not an expert so not sure which is the correct information. Maybe both are correct, each appropriate to the way the situation is being managed. Seems like a handy setting to be aware of though.

In any case there also another setting mentioned in the above linked webpage that needs to be made to get this cache in memory working, the setting: browser.cache.memory.enable must be set to true.
OS: Windows 10 Pro. x64
User avatar
therube
Posts: 21714
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Re: Possible to Force Folder "mozilla-temp-files" to a Ramdi

Post by therube »

the problem with it is that it sets those paths for all files that are written into TMP/TEMP after the batch has been used - not just for files created by Firefox

That should not be.
Only programs run from the particular batch file, or children thereof, should be affected, meaning basically FF.
Now if from within FF you ran, say Windows Explorer, then anything done from there that used %TMP% would be affected, but as that is not particularly likely to happen...

If the entire TMP/TEMP folders are moved to the ramdisk

Again, only "FF" should be redirected.

They don't want the temporary files being written to SSD because it reduces the life-span of the SSD.

That last number of reviews I read indicate (that with anything relatively current) that should be a non-issue. The SSD Endurance Experiment: Two freaking petabytes.
Fire 750, bring back 250.
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball CopyURL+ FetchTextURL FlashGot NoScript
User avatar
BuddhaNature
Posts: 537
Joined: January 3rd, 2008, 9:44 am
Location: Scotland

Re: Possible to Force Folder "mozilla-temp-files" to a Ramdi

Post by BuddhaNature »

Okay, therube. I took onboard what you say about the way the batch operates, tested it, and, yes it seems to work as you say (which amazes me). And you have solved my original query. Thank you very much. =D>

However, there is one problem in that the window to the batch when it is running stays open until such times as the user closes down Firefox. Once Firefox is closed down then the batch window closes itself.

Do you know of any way to have that batch window close down immediately after Firefox has been launched? And, if that is possible, and is done, would that still leave the TMP/TEMP stuff for Firefox still being directed to the ramdisk location?

Should say this isn't a major problem as it's easy to just minimise the batch window out of the way into the system tray. It would just be more elegant if the batch window closed itself immediately after Firefox is launched.

Edit: P.S. I just tried an experiment and manually closed the batch window after Firefox was launched using the batch. Then I went to a website that I know would create a "mozilla-temp-files" folder and put an audio content file in that folder. To my surprise, even with the batch window closed, the "mozilla-temp-files" folder and contents still did get written to the ramdisk. Amazing. Would still be better though if there was a way of getting the batch window to close itself immediately after launching Firefox.
OS: Windows 10 Pro. x64
User avatar
BuddhaNature
Posts: 537
Joined: January 3rd, 2008, 9:44 am
Location: Scotland

Re: Possible to Force Folder "mozilla-temp-files" to a Ramdi

Post by BuddhaNature »

To answer my own question on how to get the batch window to automatically close. I searched the web, messed with a cmd window for a while, and came up with the solution. A batch that will run, set the TMP/TEMP redirections, launch Firefox, and then automatically close the batch window is:

Code: Select all

set TEMP=W:\RAMDISK\TEMP
set TMP=W:\RAMDISK\TMP
start "" "C:\Program Files (x86)\INTERNET\Mozilla Firefox\firefox.exe"
exit


I did a quick couple of tests for it and it seems to work fine.

Now that I've seen that working it seems to me that is a handy bit of batch code to know. I can think of dozens of uses for it to make sure temp files created by various programs get themselves written to a ramdisk.

Thanks again therube - problem solved. Much appreciated. :D
OS: Windows 10 Pro. x64
User avatar
therube
Posts: 21714
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Re: Possible to Force Folder "mozilla-temp-files" to a Ramdi

Post by therube »

(oops. i typed this out some time ago, but never hit Submit, & now see that you've got it on your own :-))


Code: Select all

set   TMP=X:\RAMDISK\TMP
set  TEMP=X:\RAMDISK\TMP
C:\Program Files\Firefox\Firefox.exe
exit


Fart around with CMD & or START & see what they may do.

So try:

Code: Select all

CMD  /C   C:\Program Files\Firefox\Firefox.exe

Which says to start up FF & then terminate (the call to FF).
And when it terminates, it should then run the EXIT, which should close the window.
Fire 750, bring back 250.
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball CopyURL+ FetchTextURL FlashGot NoScript
Post Reply