Sneh Agrawal
Sneh Agrawal

Reputation: 29

There is any method for webview cache Optimization in flutter?

I use flutter_inappwebview for fetching the website into the flutter app. I want to save all the resources like JS and CSS file content into the cache from website during webview start and then when I call same website the resources will intercept and inject the cached files into the webview. Is this possible.. If possible then how.. please explain with example. Thank you.

Upvotes: 2

Views: 8182

Answers (2)

alireza easazade
alireza easazade

Reputation: 3802

note: caching is already enabled for this plugin by default. but what you're asking is offline-mode which flutter_inappwebview plugin does not support yet.

the cache you're refering to is not the cache that browsers use (mobile or desktop) what you're refering to is basically called offline-mode in the world of browsers.

in regard to the flutter_inappwebview plugin there is already an issue (or two) about this feature you're looking for. and i believe it is not implemented yet.

you should keep an eye on these github issues issue-561 & issue-366

Upvotes: 1

Akif
Akif

Reputation: 7640

That flutter_inappwebview package has already a property, cacheEnabled with default parameter, true. You don't need to do anything about this. If you don't want to store cache files, then you can set it to false.

 ///Sets whether WebView should use browser caching. The default value is `true`.
 ///
 ///**NOTE**: available on iOS 9.0+.
 bool cacheEnabled;

And, the clearCache property with the default value, 'false'.

///Set to `true` to have all the browser's cache cleared before the new WebView is opened. The default value is `false`.
bool clearCache;

Upvotes: 2

Related Questions