React-native-code-push: [UWP] CheckFrequency.ON_APP_RESUME always reports "up to date"

Created on 4 Oct 2016  路  9Comments  路  Source: microsoft/react-native-code-push

Thanks so much for filing an issue or feature request! Please fill out the following (wherever relevant):

  • react-native-code-push version: 0.14.6-beta
  • react-native version: 0.34.1
  • react-native-windows version: 0.34.0
  • iOS/Android version: Windows 10.0.14393
  • Does this reproduce on a debug build or release build? Debug
  • Does this reproduce on a simulator, or only on a physical device? Desktop
  • Repro steps and/or stack trace:
  • Run app with codePush.CheckFrequency.ON_APP_RESUME
  • Publish update
  • Suspend app
  • Resume app
  • CodePush always reports "App is up to date."
  • Restart app
  • CodePush downloads update

(The more info the faster we will be able to address it!)

The issue is that the ON_APP_RESUME check frequency does not work as expected and always reports that the app is up to date.

fix-in-master

All 9 comments

I'm starting to suspect this is some kind of caching behavior built into Windows.Web.Http.HttpClient.

Immediately after an update, the first update check for the given hash usually comes back with a "no update" response. Then all subsequent checks (until app restart) return that same cached response. Just a theory...

Does it still repro if you disable caching in HttpClient in react-native-windows?

Unfortunately it still repros when I set cache-control: no-cache as a header on the HttpRequest object...

But I'm not convinced that's eliminating client-side caching, and I can't find a toggle for such behavior. I could try and add a random parameter (like DateTime) to the URI to see if it still caches...

Okay, so there is more evidence in favor of the client-side caching behavior. By adding a random parameter to the updateCheck URL, the correct response comes back. Now to figure out why HttpClient could be doing this...

Okay, by setting the following on the UWP HttpClient:

``` c#
var filter = new HttpBaseProtocolFilter
{
AllowAutoRedirect = false,
};

        filter.CacheControl.ReadBehavior = HttpCacheReadBehavior.MostRecent;
        filter.CacheControl.WriteBehavior = HttpCacheWriteBehavior.NoCache;

        return new DefaultHttpClient(new HttpClient(filter));

```

Things work properly. Unfortunately, setting Cache-Control: no-cache should have also worked as expected. This is definitely a UWP bug, but I'm also curious if this could be a CodePush bug. EDIT: This is an issue with the Cache-Control header missing from the CodePush service response. Because CodePush can't really know the caching behavior of the underlying HTTP client, shouldn't it send a Cache-Control: no-cache header from the service, or use a URI on the client that changes over time (e.g., by appending a Unix timestamp to the URI to prevent such caching)?

Confirmed that if the service responded with a "Cache-Control" header, then the HttpClient would do the right thing. I'll open another issue on http://github.com/Microsoft/code-push because I don't know where else to file service bugs.

Thanks for the service update @silhouettes, this works flawlessly now!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

quanzaiyu picture quanzaiyu  路  3Comments

diegocouto picture diegocouto  路  4Comments

panarasi picture panarasi  路  4Comments

sergey-akhalkov picture sergey-akhalkov  路  4Comments

Phredward picture Phredward  路  3Comments