cordova-ios icon indicating copy to clipboard operation
cordova-ios copied to clipboard

(ios) Added a NSURLRequestReloadIgnoringLocalCacheData policy when lo…

Open BBlashko opened this issue 1 year ago • 1 comments

…ading requests

Platforms affected

  • iOS

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

  • [*] I've run the tests to see all new and existing tests pass
  • [*] I added automated test coverage as appropriate for this change
  • [*] Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • [*] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • [*] I've updated the documentation if necessary

BBlashko avatar Aug 20 '24 20:08 BBlashko

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 78.31%. Comparing base (d8ebfb3) to head (a53af63). :warning: Report is 81 commits behind head on master.

Additional details and impacted files
@@            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.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov-commenter avatar Aug 20 '24 20:08 codecov-commenter

I believe #1573 will solve this issue in a way that's more tightly scoped to just filesystem-served files. Thank you for tracking down the problem and opening pull requests!

dpogue avatar Oct 28 '25 18:10 dpogue