locked
Xap Package Caching - Significance of the Source Param RRS feed

  • Question

  • Some of our customer complain that the Xap package is being cached too often, and some of our customers complain that the Xap package is not being cached enough. Basically, I think browsers are stupid. How hard is it to check the date of the Xap package? It's not rocket science!

    Anyway, this article offers a workaround/solution for the problem where the Xap package is being cached too much:

    http://codeblog.larsholm.net/2010/02/avoid-incorrect-caching-of-silverlight-xap-file/

    What I want to understand is what the significance of the "ignore" query string as part of the "source" param is. What does it do? How does the Silverlight ActivieX object deal with this argument? I've seen other workarounds where they don't pass in an "ignore" query string - instead they simply pass in the ticks from the current Date/Time.

    I can't just blindly ram this code in to our production instances because I have no idea how this will affect each user. This might cause more caching, or cause less caching. I need some information about what this workaround actually achieves.

    Here is some background information on the Source property:

    http://msdn.microsoft.com/en-us/library/system.windows.interop.silverlighthost.source(v=vs.95).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-2

    Wednesday, March 12, 2014 11:48 PM

Answers

  • Well, in a normal situation, the parameter is used to passing some values, it is quite important for HTTP GET method to know the what is the coming query and react to the request. 

    But in your case, it is only a way to identify different xap packages.

    As I mentioned there is cache exist for helping reduce the network load. When Silverlight gets a Uri, firstly look into the cache to see if there is a exist one by Uri address. However if we add a timestamp at the end of the uri, the address looks different, and the "stupid" system will just consider: we do not have a exist one from coming URI, and we will download a new one from Internet.

    Actually it is a good question for why should I name it at all, it is syntax, and if you don't add the name, then your timestamp will be absolutely and totally ignored while Silverlight managing the uri. For instance http://www.address.com?value1 will result as http://www.address.com and you could not let the Silverlight get a latest xap package.

    Hope this helps.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, March 18, 2014 2:58 AM
    Moderator

All replies

  • Bump
    Sunday, March 16, 2014 11:15 PM
  • Hi Christian,

    Well, to add a current timestamp is a good solution for identify same xap package saved at different time. But where you see the "ignore" query string? Could you point me out the documentation?

    Bascially Source only accept Uri element, when the app use the same uri, the system will firstly search into the cache to see if the correct xap package exist, if there is, use it, if not, download from network. That's why we want to add the TimeStamp as the attached string, and if you want, you can use other random number or string instead.

    However, if you use the code with timestamp, definitely there would be much xap in your user's device, because each time user request the xap, load a new xap package.

    I would not suggest you to add a timestamp for seconds identifier, but instead you could add a timestamp as a dates identifier to reduce the frequency of the reload.

    More information can be found: http://geekswithblogs.net/mbcrump/archive/2011/01/06/prevent-your-silverlight-xap-file-from-caching-in-your-browser.aspx

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, March 17, 2014 11:33 AM
    Moderator
  • where you see the "ignore" query string? Could you point me out the documentation?

    Actually, that's the question I'm asking you. Where is the documentation?

    As I mentioned, I got it from the article mentioned above. (http://codeblog.larsholm.net/2010/02/avoid-incorrect-caching-of-silverlight-xap-file/). The line of code from the article is here:

    param = "<param name=\"source\" value=\"" + orgSourceValue + "?ignore="

    + xapCreationDate.ToString() + "\" />";

    Monday, March 17, 2014 9:22 PM
  • OK, understand your question now.

    There is no documentation for keyword "ignore" but we can simply understand it as the parameter, I believe if you use other string(for instance "kkk", "bbb"), should be fine either.

    http://www.address.com?parameter1=value1&parameter2=value2

    The ignore itself has no meaning, that's why the blog author write it as "ignore". See: Query Property

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, March 18, 2014 1:20 AM
    Moderator
  • I half understand.

    If we are naming the parameter as "ignore", what is actually looking at that parameter? Why should I name it at all? What is the significance of this argument?

    Tuesday, March 18, 2014 2:35 AM
  • Well, in a normal situation, the parameter is used to passing some values, it is quite important for HTTP GET method to know the what is the coming query and react to the request. 

    But in your case, it is only a way to identify different xap packages.

    As I mentioned there is cache exist for helping reduce the network load. When Silverlight gets a Uri, firstly look into the cache to see if there is a exist one by Uri address. However if we add a timestamp at the end of the uri, the address looks different, and the "stupid" system will just consider: we do not have a exist one from coming URI, and we will download a new one from Internet.

    Actually it is a good question for why should I name it at all, it is syntax, and if you don't add the name, then your timestamp will be absolutely and totally ignored while Silverlight managing the uri. For instance http://www.address.com?value1 will result as http://www.address.com and you could not let the Silverlight get a latest xap package.

    Hope this helps.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, March 18, 2014 2:58 AM
    Moderator