Playing around with this I find that when you choose to open a document with an external program in Firefox, what happens is that Firefox downloads the program to
/tmp and then runs the chosen program with the downloaded file as an argument (read 'opens the file with the chosen program').
If you then save the file (without choosing
Save As or the equivalent) from within the program, it will use this file in
Firefox will clean up these temporary files when it closes. So you can recover the file if you close LibreOffice, but not Firefox. However, as soon as Firefox is closed, the file will be deleted.
On most (all?) distros, the
/tmp folder will also be emptied on reboot (files in
/var/tmp should persist for longer).
Note also that this behaviour is only for 'opening' a file with an external program. If the file is opened internally via a plugin or otherwise, then it appears
/tmp is not used (the file appears to be cached elsewhere along with the web pages themselves).
For reference (I don't recommend doing this unless it is necessary), you can disable the deleting of
/tmp on files when firefox closes using the
browser.helperApps.deleteTempFileOnExit option. This can be set via the
about:config page (just type this in the address bar and press enter). If it exists and is
false, just right click on it and choose toggle. Otherwise, add it by doing Right Click->New->Boolean, then enter the name of the option and choose false.
/tmp files past the next reboot on recent Debian based systems, first look at
/etc/default/tmpfs and make sure the is no
RAMTMP=yes line. If it is commented out (
# at the start), this is fine (if it was set then
/tmp would be on a
tmpfs filesystem in memory and would not be stored on disk). Next add or change the
TMPTIME line in
/etc/default/rcS. To store
/tmp files indefinitely you can do:
Or you can use a positive number instead of
infinite to keep them for that number of days, once their time is up they will be deleted at the next reboot. Obviously if this line is commented out, uncomment it.