Does PhantomJS store any persistent files by default?

As a new user to PhantomJS I want to be sure that I understand how PhantomJS handles any persistence of data that it accumulates from a HTTP request.

My question is: Does PhantomJS store any data persistently by default (i.e. a simple example where you are not using require('fs') anywhere in the script to store the request, just dumping it out to STDOUT). I am assuming that all of the work from a page.evaluate() call is done in memory.

Here is a simple example for illustration:

var page = require('webpage').create(),
system = require('system'),

if(system.args.length != 2)
    console.log('Usage: phantomjs thisFile.js URL');
    address = system.args[1];, function (status)
        if(status !== 'success')
            console.log('Unable to load the address!');
            // Wait for the js to finish loading
                var results = page.evaluate(function(){
                    return document.documentElement.innerHTML;

                console.log(results); // This would be to stdout

            }, 200);

This script would be called by something like phantomjs thisScript.js

I know that you can save a page to file, I just want to be sure that I am aware of all the places that PhantomJS may accumulate data on its own.

I also have looked into how PhantomJS handles cookies.


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Yes, there is one type that is saved by default and this is the localStorage database.

  • On Windows 7: C:Users<user>AppDataLocalOfi LabsPhantomJS
  • On Windows 8: C:Ofi LabsPhantomJs
  • On Linux: /home/<user>/.qws/share/data/Ofi Labs/PhantomJS

Everything else is saved only when you add the commandline options. The disk cache is inside of the above directory and the cookie file path has to be set explicitly.

So it means that if the web application that you test doesn’t use localStorage then you can run PhantomJS in parallel.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x