6

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.

3
  • Did you figure this out? How did you get multiple instances to work anyway? I tried using a separate child process for each, but it didn't seem to work. Commented Apr 21, 2013 at 5:00
  • 1
    Unfortunately, as of PhantomJS 1.8 there's no way to pass in a cache directory, so all calls share the same cache if you are using one. I'm not sure if there's been an update to fix this, but I created a feature request for it: github.com/ariya/phantomjs/issues/11102 . As for how I ran multiple instances, I chose option #2 from this answer: stackoverflow.com/a/9978162 . Commented Apr 22, 2013 at 12:45
  • Ah, I went down the path of option #1 because I'm passing a javascript function for the page to evaluate, and option #1 seemed easier for me. I wrapped the nodejs module in its own child process. However, I can't seem to make two calls with two child processes concurrently. Commented Apr 22, 2013 at 14:12

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.