locked
Output caching for client does not work RRS feed

  • Question

  • Hello:

    I'm trying to setup the output caching for a WCF RIA service. For some reason, it only works for server location and does not work for client location.

     [OutputCache(OutputCacheLocation.Server, duration: 100)] // Works

     [OutputCache(OutputCacheLocation.Client,duration:100)] // Does not work

    Inspite of setting the cache location as "Client", Silverlight simply makes a roundtrip instead of using the local cache. Is there anything else to be done to enable client side caching.

    Please advice

     


     

    Thursday, July 21, 2011 1:34 PM

Answers

  • I found the solution finally. When you test the chaching behaivour using http://localhost  IE simply does not cache the objects. Change the use of “localhost” in the URL in your browser’s address bar to “127.0.0.1.” (the localhost loopback IP address, including the final dot). This simply tricks IE and magically enables caching!! Hopefully this will save some frustrating cycles.

    Monday, August 15, 2011 3:02 PM

All replies

  • The above works fine with fier-fox. The only way I can get this working in IE is by adding the following in the Silvelright Application_Startup

       private void Application_Startup(object sender, StartupEventArgs e)
            {
                var t = App.Current.Host.Source.Host;
                var p = App.Current.Host.Source.Port;
                var s = "/ClientBin/OutputCaching-Web-ProductList.svc/binary/GetProducts";
                var complete = string.Format("http://{0}:{1}{2}", t, p, s);
    
                HttpWebRequest.RegisterPrefix(complete, WebRequestCreator.ClientHttp);
    
    
                
                this.RootVisual = new MainPage();
            }

    Not sure why the above works.

    Thursday, July 21, 2011 3:28 PM
  • It stopped working inspite of the above code in IE. It worked for sometime, and for no reason suddenly stopped working. I'm clueless.

    • Proposed as answer by Ghost4254 Saturday, April 11, 2015 6:41 PM
    • Unproposed as answer by Ghost4254 Saturday, April 11, 2015 6:41 PM
    Monday, July 25, 2011 2:36 PM
  • Hi,

    I'm trying to setup the output caching for a WCF RIA service. For some reason, it only works for server location and does not work for client location.

    According to your description ,I would like to suggest you to check the link below for an article which explains about RIA Services Output Caching.

    RIA Services Output Caching

    Inspite of setting the cache location as "Client", Silverlight simply makes a roundtrip instead of using the local cache. Is there anything else to be done to enable client side caching.

    In addition ,here is a similar thread which provides some solutions for the same issue ,please check it and see whether it helps.

    Output Caching not working in RIA Services

    Hope it can help you.

    Wednesday, July 27, 2011 9:34 PM
  • Ming - I have already gone through all those links. It does not help unfortunatly

    Wednesday, July 27, 2011 10:02 PM
  • I found the solution finally. When you test the chaching behaivour using http://localhost  IE simply does not cache the objects. Change the use of “localhost” in the URL in your browser’s address bar to “127.0.0.1.” (the localhost loopback IP address, including the final dot). This simply tricks IE and magically enables caching!! Hopefully this will save some frustrating cycles.

    Monday, August 15, 2011 3:02 PM