How do you force Firefox to not cache or re-download a Silverlight XAP file?

后端 未结 17 684
渐次进展
渐次进展 2020-11-29 02:07

When working with Silverlight, I\'ve noticed that Firefox will cache the XAP file, so if I do an update, a user may be stuck using an outdated version. Is there a way to fo

相关标签:
17条回答
  • 2020-11-29 02:13

    Another solution would be to append the version of the XAP file rather than a timestamp. The timestamp would change every time (might as well turn off caching). To get it to only change when the XAP has been updated would be to take some info from the XAP file. Am still looking into what I could use, perhaps the last modified datestamp of the XAP file?

    0 讨论(0)
  • 2020-11-29 02:18

    You might find the Caching Tutorial for Web Authors and Webmasters helpful. This document discusses the different caches through which the client and server interact (browser, proxy, gateway) and how caching can be controlled.

    0 讨论(0)
  • 2020-11-29 02:20

    This tested and working:

    Put this:

    <%
        const string sourceValue = @"ClientBin/MyXapFile.xap";
        string param;
    
        if(System.Diagnostics.Debugger.IsAttached)
            param = "<param name=\"source\" value=\"" + sourceValue + "\" />";
        else
        {
            var xappath = HttpContext.Current.Server.MapPath(@"") + @"\" + sourceValue;
            var xapCreationDate = System.IO.File.GetLastWriteTime(xappath);
    
            param = "<param name=\"source\" value=\"" + sourceValue + "?ignore="
            + xapCreationDate + "\" />";
        }
        Response.Write(param);
    %>
    

    Instead of this:

    <param name="source" value="ClientBin/MyXapFile.xap" />
    
    0 讨论(0)
  • 2020-11-29 02:21

    You could send HTTP headers to prevent it from caching:

    Cache-control: no-cache
    Pragma: no-cache
    

    How you do this depends on the web server you're using.

    0 讨论(0)
  • 2020-11-29 02:22

    Adding the timestamp for the XAP worked for me (I'm adding the SL control in javascript but this could just as easily be done inline):

    var appTimestamp = '<%= System.IO.File.GetLastWriteTime(Server.MapPath("ClientBin/MyApp.xap")) %>';
    var source = 'ClientBin/MyApp.xap?appTimestamp=' + appTimestamp;
    
    0 讨论(0)
  • 2020-11-29 02:23

    I use this solution

    <object id="Xaml1" data="data:application/x-silverlight-2," type="application/x-silverlight-2"
    width="100%" height="100%">
    <%––<param name="source" value="ClientBin/SilverlightApp.xap"/>––%>
    <%
    string orgSourceValue = @"ClientBin/SilverlightApp.xap";
    string param;
    if (System.Diagnostics.Debugger.IsAttached)
    param = "<param name=\"source\" value=\"" + orgSourceValue + "\" />";
    else
    {
    string xappath = HttpContext.Current.Server.MapPath(@"") + @"\" + orgSourceValue;
    DateTime xapCreationDate = System.IO.File.GetLastWriteTime(xappath);
    param = "<param name=\"source\" value=\"" + orgSourceValue + "?ignore="
    + xapCreationDate.ToString() + "\" />";
    }
    Response.Write(param);
    %>
    <param name="onError" value="onSilverlightError" 
    
    0 讨论(0)
提交回复
热议问题