Reputation: 2063
I want to cache the web page I display in flutter webview so to improve my performance, no need to reload the page. Is that available? and can I implement it?
Upvotes: 7
Views: 26340
Reputation: 54367
flutter_inappwebview(former flutter_inappbrowser)
Has parameter cacheEnabled
. Default value is true.
cacheEnabled
sets whether the WebView should use browser caching
flutter_webview_plugin community version
Has parameter appCacheEnabled
to enable cache
WebviewScaffold(
key: _scaffoldKey,
url: widget.url,
clearCache: true,
appCacheEnabled: true,
);
webview_flutter official version
Do not provide parameter , you can check with Android Source code
https://github.com/flutter/plugins/blob/master/packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterWebView.java
Default cache mode depend on iOS WKWebView
and Android
WebView
Default cache mode of Android WebView
is LOAD_DEFAULT
https://developer.android.com/reference/android/webkit/WebSettings#LOAD_DEFAULT
Default cache usage mode. If the navigation type doesn't impose any specific behavior, use cached resources when they are available and not expired, otherwise load resources from the network.
Upvotes: 8