Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does phantomjs regularly clear its cache automatically?

I need to change the default time of automatic cache clear for Phantomjs if there is such a feature. Any idea?

like image 444
PHA Avatar asked Mar 05 '15 10:03

PHA


2 Answers

Should be the feature that you are looking for:

https://github.com/ariya/phantomjs/issues/10357

page.clearMemoryCache()
like image 98
superhero Avatar answered Oct 15 '22 20:10

superhero


Each PhantomJS process has its own in-memory cache, so there is no need to clear it between script executions. You can let PhantomJS save the cache in disk, so that it persists accross executions. See the --disk-cache option.

There is no way to clear the cache during a script execution.

localStorage on the other hand is persisted every time and you cannot turn it off. So you may need to add the following snippet before exiting PhantomJS.

page.evaluate(function(){
    localStorage.clear();
});
like image 25
Artjom B. Avatar answered Oct 15 '22 20:10

Artjom B.