URLConnection Caching Data on Windows

Hi Everyone,

I have an API that I am trying to call from a desktop app. I used to use MBS CURL to connect, but an update to my server made that only return 500 Server Error (not sure what is going on there).

So I attempted to switch to URLConnection. It works great on Mac, but on Windows it seems to be encountering some kind of caching.

One of the API results is the number of records in each database table. When I check for an update, I see if the number of records has changed since the last update. If so, I download the newest data.

But, what happens is the app is caching this API result. So whenever I hit the URL it looks like the number of records has not changed. That leads to the app never knowing it needs to update the data.

Like I said, this only happens on Windows, so I don’t think it’s a server issue, but just to be sure I:

  1. added a random string of numbers as a query string the the URL
  2. added no-cache headers to the api endpoints

Neither had any effect. I also tried using URLConnection.ClearRequestheaders to see if that made a difference, but it didn’t.

Has anyone been able to get around this by changing your code, your API endpoint or some kind of Windows setting?

Thank you!

-Mike

Are you receiving 200 OK?

Are you re-using the same URLConnection instance or creating a new one each time?