I am using java.net to create a simple request with a URL. This url returns a unique result each time. When the app is on the dev server everything works fine. When deployed to GAE the same result is returned over and over again no matter how many times I call the url. If I copy and paste the actual URL into a browser it returns a new unique result each time the request is made thus working as intended. What is likely to be causing this issue? Any help would be greatly appreciated.
Asked
Active
Viewed 143 times
0
-
2you can add the current time milliseconds to the url to prevent caching "myurl.jsp?milli=12012542101" – Logan Murphy Aug 07 '13 at 14:29
-
The api I am requesting returns invalid parameter when I add milli or something similar as a value to the request. – Chris Vaught Aug 07 '13 at 17:13
-
Set the cache control header of your page to NO-CACHE. See http://stackoverflow.com/questions/4480304/how-to-set-http-headers-for-cache-control – Philippe Aug 07 '13 at 17:24
-
I tried that but it did not fix the issue. – Chris Vaught Aug 07 '13 at 17:52
2 Answers
0
Try using the URLConnection class, let me know how it works out, the issue may be caching
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
public class Test {
public static void main(String[] args) throws IOException {
System.out.println(getData("http://www.google.com/"));
}
public static String getData(String path) throws IOException {
URL url = new URL(path);
URLConnection urlc = (URLConnection) url.openConnection();
urlc.setUseCaches(false);
urlc.connect();
InputStream is = urlc.getInputStream();
String s = "";
int info;
while ((info = is.read()) != -1) {
s += (char) info;
}
is.close();
return s;
}
}

Logan Murphy
- 6,120
- 3
- 24
- 42
-
I actually have primarily been using HttpURLConnection all along. I have setUsesCaches(false) and it did not fix the issue. – Chris Vaught Aug 07 '13 at 17:53
0
Did you try to empty the cache in the browser to discard caching issues. also might be caching at the network level. Also Try other common timestamp params like ts,timestamp,etc. Maybe the service will accept one.

Zig Mandel
- 19,571
- 5
- 26
- 36
-
Thank you for the suggestion. I was able to add the parameter "_" to fix the issue and the service would ignore it. – Chris Vaught Aug 07 '13 at 22:28