Odd caching behaviour in the native binary?

We’re currently preparing an Ionic 4 application for iOS and Android release. Across both platforms I’ve observed this behaviour:

  1. We use a custom component to fetch and display (basically figure > img) because our image API is programmatic. This component just calls a service to fetch the image and turn the blob into a URL.
  2. Before the user shuts down the app, this works totally fine. It displays correctly.
  3. After the user restarts the application, and older version of this component displays with a placeholder graphic.
  4. All instances of this component use the same placeholder graphic.

At this point in time I have removed both the placeholder graphic and all references to it from our code. It appears that after the user restarts the application it shows the older component.

In the screenshot above, a broken “image not found” graphic should show, not the placeholder. Steps to build application:

  1. rm -rf www
  2. ionic cordova platform rm ios && ionic cordova platform add ios
  3. ionic cordova prepare ios (in this case)
  4. Build in xcode.

It’s always the same pattern. New component before build, old component after. What the heck?

Sounds interesting (/ weird). Could it be possible, that your Server / API returns some (wrong?) headers for the images itself? Something like the time to cache, revalidate or Cache-Control in general? That would mean, that the client do not request images on each app start after the first one.

Maybe you should checkout a documentation about Image Caching, f. e.: https://varvy.com/pagespeed/cache-control.html

You can debug the devices network traffic with the Chrome- or Safari-Inspector to check this. Maybe a error is thrown too?

Hope it helps :-).

Cheers
Unkn0wn0x

1 Like

@Unkn0wn0x Header caching is not the issue. Requests are programmatic, though I’m happy for the browser to cache subsequent results. Literally, more and more it looks like the native application is caching and loading fragments from older versions of the application.

Well I solved it:

  1. We pushed out native test releases through the Google Play and iTunes stores so that our testers would stay up to date, because they’re more likely to install and try out new features when notified through those channels.
  2. Our builds have OTA updates enabled.
  3. Our last OTA build is behind latest production.
  4. Whenever the app launches it pulls down the latest OTA release.
  5. When the app is killed and restarted it applied the OTA.

Listos version: The app regressed to an earlier OTA release.

Great you’ve found a way around it :slight_smile:

One thing I could imagine is, that the Build from Xcode stays in conflict with the Ionic Build Script.

Could you test, if the following command works, like expected?

ionic cordova run ios --prod

Cheers
Unkn0wn0x