We have a automation testing tool to record and replay. We will launch this tool using jnlp file.
After opening the tool, if we record on a instance, response is fine. But if we record on the same instance second time, getting cached response.
If we close the tool and record, working fine. So, getting problem when our tool is alive.
We are using HTTPURLConnection
to read response from Server. We tried setting the headers Pragma:no-cache", "Cache-Control:no-cache,no-store,must-revalidate
. But no use.
Here is our code snippet...
OutputStream sharedProxyNWebOutStream = null;
URL requestURL = new URL(requestFromBrowser.url());
HttpURLConnection webConnection =(HttpURLConnection)requestURL.openConnection();
webConnection.setDoOutput(true);
sharedProxyNWebOutStream = webConnection.getOutputStream();
sharedProxyNWebOutStream.write(requestFromBrowser.data());
We have tried all solutions mentioned in the Java - HttpUrlConnection returns cached response every time. But no luck.