You set them on the about:config page. I don't know about the history directory setting, but the cache setting can be changed by adding a new string called ...
browser.cache.disk.parent_directory
and set the value to whatever directory you want. Something like "C:\temp\firefox" or whatever. Firefox will then create another directory under that one called "cache" where it will store the cache files.
I wouldn't be surprised if there was an extension to change these settings as well.