Tatsuya Sasaki
Tatsuya Sasaki

Reputation: 23

PhantomJS: A resource request is only once when plural page opened

When phantoms opened page A and B, resource request for common.css is only once.

--

Sample Code:

casper.on('resource.requested', function(req) {
    if (req.url.indexOf('common.css') != -1) {
        util.dump(req);
    }
});

--

How send resource request in each time?

Thanks.

Upvotes: 1

Views: 394

Answers (1)

Cybermaxs
Cybermaxs

Reputation: 24558

That's because of the memory cache. As a headless browser, phantomJS has a browser cache for HTTP requests (base upon HTTP headers). All page instances use the same memory cache, that's why the same ressource is requested only once.

I know there is a pull request for clearing cache between requests, but this is quite new and won't be merged until at least 2.0 (no release date).

The only solution that I've found now is to spawn a new phantomjs process for each test (with no disk cache of course).

Upvotes: 1

Related Questions