Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhantomJS keeping cache

I am using phantom js to test accessing a webpage, this runs approximatley 350 times in the space of about half an hour. I am then running webalizer against the server to test page accesses.

My phantom js clients are inside 1 instance of phantom js so it basically works in the sense that once one client has opened the web page kick off the next client, all with individual IP addresses and MAC addresses throughout.

However what I am finding in webalizer is that while I get 350 hits to the server I am only getting 1 hit per instance of phantomjs I run on some css files and others. So I have come up with the idea of it caching clients together.

I have attempted running --max-disk-cache-size=0 when calling the phantom js instance but still see it acting the same.

Has anyone experienced the same before?

like image 883
Charabon Avatar asked Apr 30 '14 14:04

Charabon


People also ask

How does PhantomJS work?

PhantomJS is a discontinued headless browser used for automating web page interaction. PhantomJS provides a JavaScript API enabling automated navigation, screenshots, user behavior and assertions making it a common tool used to run browser-based unit tests in a headless system like a continuous integration environment.

How do I get PhantomJS path?

For WindowsDownload the zip file, unpack it and you will get an executable phantom.exe. Set the PATH environment variable to the path of phantom.exe file. Open a new command prompt and type phantomjs –v. It should give you the current version of PhantomJS that is running.

How do I run PhantomJS?

Go to the “bin” folder and check phantomjs.exe file. If you are using it on a Windows OS, then you can set the path variable under the environment variable for fast access through command prompt. The command to run the PhantomJS program: C:\> phantomjs [options] file.


1 Answers

Run page.clearMemoryCache(); before page.open can clean cache.

It metioned in this issue, and it works fine in PhantomJS 2.0.

like image 107
Fancyoung Avatar answered Oct 24 '22 14:10

Fancyoung