2

I am trying to call the same link, but with different values, the issue is that the url is correct containing the new values but when I download it (Webclient.DownloadStringTaskAsync), it gives me the previous calls result.

I have tried adding headers no-cache, and attaching a random value to the call, and ifmodifiedSince header. however it is still not working.

any help will be much appreciated cause I have tried everything.

uri: + "&junk=" + Guid.NewGuid());

  client.Headers["Cache-Control"] = "no-cache";

  client.Headers[HttpRequestHeader.IfModifiedSince] = DateTime.UtcNow.ToString();


  var accessdes = await client.DownloadStringTaskAsync(uri3);

so here my uri3 contains the latest values, but when I hover over accessdes, it contains the result as if I am making a old uri3 call with previous set data.

Bohrend
  • 1,467
  • 3
  • 17
  • 26
  • Is your phone using a service of the provider that caches web requests? – Emond Nov 15 '13 at 12:20
  • is it possible for the server to ignore the random value added to the url? – Bohrend Nov 15 '13 at 12:26
  • It might be in the bowser settings or somewhere else in the global settings depending on the provider. Have a look at this as well: http://stackoverflow.com/questions/4461610/wp7-httpwebrequest-without-caching/9208636 and http://stackoverflow.com/questions/6334788/windows-phone-7-webrequest-caching – Emond Nov 15 '13 at 12:26
  • have tried all of those – Bohrend Nov 15 '13 at 12:37
  • Does it happen in both the device and the emulator? – Emond Nov 15 '13 at 12:48
  • only have device, pc OS not correct version of windows 8 to run emulator – Bohrend Nov 15 '13 at 12:49
  • Have a look at this too: http://stackoverflow.com/questions/3812089/c-sharp-webclient-disable-cache could it be that the server is caching? – Emond Nov 15 '13 at 13:04
  • is it possible for the server to cache? cause in that case I cant do anything my side? – Bohrend Nov 15 '13 at 13:05
  • Yes, it could cache. You could try to put the url in a browser or other tool to issue the request and try. If the server caches inappropriately you should inform the owner of the server. But first make sure it caches without allowing you to force a refresh! – Emond Nov 15 '13 at 13:13
  • Today, I had a similar problem and since I had not found this thread, posted a question on SO: http://stackoverflow.com/questions/25283411/content-webservice-call-not-refreshed-in-windows-phone?noredirect=1#comment39401988_25283411 I know for sure that the server doesn't cache the results, so the caching has to happen on the phone. So where does this caching on the phone take place? – SimonAx Aug 13 '14 at 21:20

1 Answers1

0

I saw one friend that was attaching a random GUID to the Url in order to prevent the OS to cache its content. For example: if the Url were: http://www.ms.com/getdatetime and the OS is caching it. Our solution was adding a guid for creating "sort of" like a new url, as an example our previous Url would look like: http://www.ms.com/getdatetime?cachebuster=21EC2020-3AEA-4069-A2DD-08002B30309D

(see more about cache buster : http://www.adopsinsider.com/ad-ops-basics/what-is-a-cache-buster-and-how-does-it-work/ )

hmadrigal
  • 1,020
  • 11
  • 19