0

So I am using a "Updater.exe" which is reading an XML file on my webserver. The Updater checks if a new version of the program is available who transfers the new file (replacing the old one) and runs it. (The file name is gibberish as i dont want users to run it directly, it has to go trough the updater (who runs it with the help of p.StartInfo.UseShellExecute = false;)).

I have now encountered a really weird "bug" or how should i call this.

Lets say i make a new version after 1 week. I update the assembly info of the application and the XML file version aswell. Now when i run the UPDATER.exe, he does not see the new updated XML content, telling him a new version is available. As i wanted to check the file trough my web browser it was also showing the OLD content (previous version) meaning, the application is UP to DATE which is false.

After i pressed the "refresh" button in Chrome, the content i had displayed was updated and running the Updater.exe again worked fine.

I do not have any IDEA what is actually going on. What does "refreshing" the page in the browser has to do with my application?

Checking the XMLTextReader class from MSDN it says:

Represents a reader that provides fast, non-cached, forward-only access to XML data. So yeah, searching the internet telling me i should lookup for "caching" issues, makes me even more confused when i read the class description. After refreshing in the browser after such a long period of no updates, all next updates are working just fine. Seems that the "big pause" always makes this problem.

Anyway, i would love to find a solution to this. Maybe it is just ME that has this problem. But i dont want to see this problem from the users using the application. They do not have time or knowledge to "refresh" anything. It just has to work.

The XML example is here:

<?xml version="1.0" encoding = "utf-8" standalone="yes"?>
<Application>
    <version>2.0.0.16</version>
    <url>http://server/folder/gibberish.extension</url>
</Application>

And some code I use to read the XML.

Version newVersion = null;
string xmlUrl = "http://server/folder/file.xml";

XmlTextReader reader = null;
try
{
    reader = new XmlTextReader(xmlUrl);
    reader.MoveToContent();
    string elementName = "";
    if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "Application"))
    {
        while (reader.Read())
        {
            if (reader.NodeType == XmlNodeType.Element)
            {
                elementName = reader.Name;
            }
            else
            {
                if ((reader.NodeType == XmlNodeType.Text) && (reader.HasValue))
                {
                    switch (elementName)
                    {
                        case "version":
                            newVersion = new Version(reader.Value);
                            break;

                            case "url":
                                downloadUrl = reader.Value;
                                break;
                    }
                }
            }
        }
    }
}
catch (Exception ee)
{
    //catch error
}

I did my best to describe the problem as detailed as i can(with my simple knowledge in english language) here. And i searched the internet with no luck. I hope this will not result in a duplicate. IF you have any other questions, feel free to ask. I will definitely give you all the information you need to solve this weird puzzle.

Best Regards, MiKE

MiKE
  • 524
  • 6
  • 12

1 Answers1

0

The first thing that comes to my mind is CDNs. Do you use any kind of CDNs such as CloudFlare? CloudFlare and similar CDNs cache your content for a short time causing this effect.

puttu
  • 969
  • 7
  • 10
  • I am not familiar with that. Where should i check up for that? On my webserver or my windows application? If that is some default feature it is worth looking into. – MiKE Nov 04 '14 at 13:21
  • You should check your server. some hosting providers provide a option in the control panel to enable/disable cloudflare (It reduces server load by caching and handling some requests) – puttu Nov 04 '14 at 13:27
  • Well, based on this link: http://www.clearcenter.com/support/documentation/user_guide/web_proxy My server does use a "web proxy" that helps browsing make faster by using cache. But this is the server located at home(for my local network). The server where the file is located does not use this web proxy. So maybe it could be the case that just i have this prolem because my home server is using it. But is this not somehow a conflict with the class description saying it represents a non-cached reader? Shouldnt it be overriden then? – MiKE Nov 04 '14 at 13:41
  • If you have a local web proxy there is a good chance that it is causing the problem as web proxy caches requests going through it. In case of XmlTextReader the term "non-cached" only says that XmlTextReader class itself not cache any request. (every time it sends out a fresh web request but web proxy returns a older version of the file.) – puttu Nov 04 '14 at 14:19
  • I shall lower the amount of MB it can store and will follow the results. I will mark your answer as corret when i found it really helped. I hope you understand. – MiKE Nov 04 '14 at 16:38
  • Try disabling it and test, as your XML file may be too small and will get cached. – puttu Nov 05 '14 at 06:15