0

Right now I am accessing data from web server. But main problem I was facing right now it that I can't able to access recent data on the spot. Not always this is happening but mostly it is taking 5 to 10 minutes delay.

If same URL, I paste into browser then I have latest data access over their but Unity have older data to display. After few minutes automatically Unity has latest data.

I want accuracy in data retrieval as browser has. At present I am using following code for fetching data from web server.

     WWW www = new WWW (url);

     //Load the data and yield (wait) till it's ready before we continue executing the rest of this method.
     yield return www;

     if (www.error == null) {
         //Sucessfully loaded the XML
         Debug.Log ("Loaded following XML " + www.text);

     } else {
         Debug.Log ("ERROR: " + www.error);
     }

If any other way exist that can solve my problem then give me help in this.

Siddharth
  • 4,142
  • 9
  • 44
  • 90
  • 1
    Did you try using unique URLs each time? Perhaps by appending something as simple as a timestamp. Say your resource is at `http://yourdomain.com/data/myresource.txt` then instead of using that each time, instead append `?t=1464940085` (current Unix time, or whatever will be unique with each call) to get `http://yourdomain.com/data/myresource.txt?t=1464940085`. Or, of course, if you have access to the server itself, set it to not cache the resource. – Bart Jun 03 '16 at 07:48
  • @Bart Whether web developer need to do anything in this? Because I am programmer so that I am asking this question. If just I add this flag and this thing will work!!! – Siddharth Jun 03 '16 at 07:53
  • 1
    The latter option does involve your web developer, yes. The former should generally "just work", so may be worth a try. – Bart Jun 03 '16 at 08:00
  • @Siddharth If this problem is not solved, check this answer out http://stackoverflow.com/a/38366659/3785314 . That will likely solve your problem. – Programmer Jul 16 '16 at 05:18
  • @Programmer can you please give me reply for following: http://stackoverflow.com/questions/37853659/data-pass-using-post-method-webrequest-object – Siddharth Jul 16 '16 at 12:59
  • In that I can't able to find a way for passing headers and arguments in UnityWebRequest object POST method. – Siddharth Jul 16 '16 at 13:00

0 Answers0