Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying a different cache directory for each instance of phantomjs

Tags:

phantomjs

I'm using PhantomJS 1.8 and ran into a limitation -- you can't specify what directory it uses for the disk cache. I added this to their issue tracking system, but since it wasn't in there before, I wouldn't expect it to be added soon.

So, I'm looking for some way around this limitation. What I'm trying to do is have multiple Phantomjs processes running, each with their own, separate, cache directory. Is there a way I can do this until the feature gets added to phantom?

How does phantom even determine which directory to use for cache in the first place? If it's based on an environment variable, maybe there could be some way I set a different value for that variable for each instance of PhantomJS that I have running.

like image 973
Borys Avatar asked Feb 27 '13 17:02

Borys


1 Answers

Under PhantomJS 1.9 at least, the cache directory is $HOME/.qws/cache/Ofi Labs/PhantomJS, so if you modify the HOME environment variable before running PhantomJS, you could have a different disk cache for each process. I tested this and it works for me.

like image 63
Bluby Avatar answered Oct 05 '22 06:10

Bluby