So i have this script
<?php
require_once('../_libTest/__init__.php');
class cacheTest
{
private $driver;
function __construct()
{
$host = 'http://localhost:4444/wd/hub'; // this is the default
//$capabilities = array(WebDriverCapabilityType::BROWSER_NAME => 'chrome');
$capabilities = DesiredCapabilities::chrome();
$options = new ChromeOptions();
/*$options->addExtensions(array(
'3.2.1_0.crx'
));*/
$capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
$this->driver = RemoteWebDriver::create($host, $capabilities,86400000,86400000);
}
function run()
{
$url = "https://www.google.com.au/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png";
$this->driver->get($url);
$filename = explode("/",$url);
$filename = end($filename);
$image = file_get_contents($url);
file_put_contents($filename,$image);
//$this->driver->quit();
}
}
$app = new cacheTest();
$app->run();
?>
using the Selenium standalone server, the Chrome Webdriver and this PHP Web Driver (edited to remove all the namespaces) with all the file includes in the __init__.php
file i can open up a Chrome Browser Window, go to the url of the google logo image then download it using file_get_contents
and file_put_contents
however i am wondering, since to save time browsers will oftern cache images (thus the option in Chrome's clear browsing history "Caches images and files") when i run Selenium and navigate directly to an image, when i use file_get_contents
is this then getting the browser's cached image or am i getting a fresh image strait from the server?
According to answers here and here the answer may be no however in my case i am loading up the page first via ->get($url)
first