apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.16k stars 986 forks source link

(ios) Added a NSURLRequestReloadIgnoringLocalCacheData policy when lo… #1471

Open BBlashko opened 3 months ago

BBlashko commented 3 months ago

…ading requests

Platforms affected

Motivation and Context

There is a problem with iOS where the diskcache aka .js, html, and css etc files are cached between .ipa installs.

When updating .ipa bundles in the Apple AppStore, it was evident that when using the fileURL system the WKWebView holds onto a previously cached cordova framework files. This can result in a fatal when booting the application if you remove a plugin. If this happens the cordova_plugins.js file doesn't get updated, so it tries to load the deleted plugin. This creates a hard blocking result, since the plugin files don't exist, so cordova cannot load the plugin (even though it should be removed)

There is no issue for this at this time, I was discussing it with Norman Breau in the Slack Space

Description

This is a follow up Pull Request to this request: https://github.com/apache/cordova-ios/pull/1451

Instead of flushing cache at the boot of the cordova framework. It was suggested to just ignore local cache when loadRequest() is called.

So when cordova runs the loadRequest function in the CDVWebViewEngine.m file, we apply a NSURLRequestReloadIgnoringLocalCacheData cache policy to the request. This should ignore any cached instances and pull the files directly

Testing

Loaded our local dev app with the new policy applied to requests. Inspected the Network of the device to track down if the app is using files from the WKWebView Cache or not.

We also are still getting these errors into our error reporting systems.

Module branch-cordova-sdk.Branch does not exist.

I can validate that these start to stop coming in completely on the new version of our production application.

Checklist

codecov-commenter commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 78.31%. Comparing base (d8ebfb3) to head (a53af63). Report is 11 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1471 +/- ## ========================================== - Coverage 78.35% 78.31% -0.05% ========================================== Files 16 16 Lines 1825 1826 +1 ========================================== Hits 1430 1430 - Misses 395 396 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.