Reputation: 1668
I need to change the default time of automatic cache clear for Phantomjs if there is such a feature. Any idea?
Upvotes: 14
Views: 16771
Reputation: 6482
Should be the feature that you are looking for:
https://github.com/ariya/phantomjs/issues/10357
page.clearMemoryCache()
Upvotes: 11
Reputation: 61892
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();
});
Upvotes: 7