Always get older version of file when downloading it from server?

Greetings,

There’s a text file on our server with some config/settings. I’m trying to download it and read the values in the game. Here’s my download routine:

IEnumerator DownloadRoutine()
{
    string url = "http://path/to/directory/settings.txt";

    using (var www = new WWW(url))
    {
        yield return www;
        if (www.error != null)
            throw new Exception("WWW download had an error:" + www.error);

        print(www.text);
    }
}

So I create the settings file with an initial version, say containing the line “data1 = value1”
The download routine works perfectly, and on the ‘print’ I see the settings.

The problem is if I then change the settings file by adding another line “data2 = value2”, I still get the previous version of the file so the printout prints “data1 = value1” as if I didn’t add the second line.

I’m not an expert on networking/webstuff so I’m not sure what I’m missing.

I’m on Windows 7 Professional accessing the server and adding/modifying the files via WinSCP. There are options in it to clear cache but it doesn’t seem to have any effect. So I’m not sure if the older values are being cached somehow or not…

Any ideas?

Thanks.

I’ve had this issue before. Here’s a simple solution to a difficult problem. Change your URL to include a random string.

// Just create some random string here
string randomString = new GUID.ToString();

string url = string.Format("http://path/to/directory/settings.txt?c={0}", randomString);

The problem is that web servers cache data, so you have to kind of force it to ignore the cache settings. The random string causes it to do this because it now caches the results with the random string at the end.