Skip to content

Commit

Permalink
Added no-cache header to HTTP GET command of RemoteWebDriver
Browse files Browse the repository at this point in the history
When Selenium RemoteWebDriver is connecting to Selenium Server
(e.g. SauceLabs) through HTTP proxy, same/repetitive HTTP commands
can be cached by the proxy. This leads to unexpected and unwanted
behavior that HTTP commands return cached and outdated data from the
server (e.g. screenshots).

To fix this I have added Cache-Control: no-cache HTTP header.

Selenium Java implementation has this fix for a while – at least from
version 2.26.

Fixes #5404

Signed-off-by: Jim Evans <james.h.evans.jr@gmail.com>
  • Loading branch information
dnknitro authored and jimevans committed Feb 15, 2018
1 parent ea99e18 commit b019171
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dotnet/src/webdriver/Remote/HttpCommandExecutor.cs
Expand Up @@ -163,6 +163,10 @@ private HttpResponseInfo MakeHttpRequest(HttpRequestInfo requestInfo)
requestStream.Write(data, 0, data.Length);
requestStream.Close();
}
else if (request.Method == CommandInfo.GetCommand)
{
request.Headers.Add("Cache-Control", "no-cache");
}

HttpResponseInfo responseInfo = new HttpResponseInfo();
HttpWebResponse webResponse = null;
Expand Down

0 comments on commit b019171

Please sign in to comment.