React Native WebView 中的 incognito 和 cacheEnabled 道具有什么区别? [英] What is the difference between incognito and cacheEnabled props in React Native WebView?

查看:66
本文介绍了React Native WebView 中的 incognito 和 cacheEnabled 道具有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我有一个基本的英语水平,所以我希望你能理解.

First of all, I have a basic level of English so I hope that you understand.

React Native WebView 中的 incognito 和 cacheEnabled 属性有什么区别?react-native-webview doc没有详细解释.

What is the difference between incognito and cacheEnabled props in React Native WebView? react-native-webview doc don't have a detailed explanation.

隐身在 WebView 的生命周期内不存储任何数据.

缓存启用设置 WebView 是否应使用浏览器缓存.

推荐答案

基于源码,iOS和Android的功能不同:

Based on the source code, the functionality is different between iOS and Android:

iOS:

使用 WKWebsiteDataStore.nonPersistent,它不向磁盘存储任何内容.

Uses WKWebsiteDataStore.nonPersistent, which does not store anything to the disk.

安卓:

  1. CookieManager 中删除所有 cookie.
  2. 清除所有缓存、表单、密码等并禁用缓存
  3. 将缓存模式设置为 LOAD_NO_CACHE(始终来自网络)
  1. Removes all cookies from CookieManager.
  2. Clears all caches, forms, password etc. and disables caching
  3. Sets cache mode to LOAD_NO_CACHE (always from network)

除第一步之外的所有内容也适用于 cacheEnabled=false.我不确定 WKWebView 中的缓存是如何工作的.默认情况下,它可能不会缓存任何内容,这意味着隐身功能与 Android 一致.cacheEnabled=true/false 在 iOS 中什么都不做.

All other than the first step also apply to cacheEnabled=false. I'm not sure how caching works in WKWebView. It may not cache anything by default, which would mean the incognito functionality is inline with Android. cacheEnabled=true/false does nothing in iOS.

这篇关于React Native WebView 中的 incognito 和 cacheEnabled 道具有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆