HttpWebRequest and HttpWebResponse shows old data

萝らか妹 提交于 2019-11-29 12:27:54

I am facing same problem, and i solved by add response header in my server side like this..

response.setHeader("Cache-Control", "no-cache");

may be this will help you too.

It seems like HttpWebRequest is returning cached result. You got a few ways to avoid that:

  1. Add a random string to the URL, so a different URL is accessed every time (so www.example.com/page becomes www.example.com/page?random=dsa$fds21).
  2. Disable the response cache, see new code to be added to OnNavigatedTo:

-

HttpWebRequest UserDetailRequest = (HttpWebRequest)HttpWebRequest.Create(UserDetailUrl); 
// Define a cache policy for this request only. 
HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
request.CachePolicy = noCachePolicy;

If your using your own API try turning caching off from that side.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!