in Ionic by
Q:
What is the advantage of caching the views in Ionic apps?

▼ Show 1 Answer

0 votes
by
By default, views are cached to improve performance. When a view is navigated away from, its element is left in the DOM, and its scope is disconnected from the $watch cycle. When navigating to a view that is already cached, its scope is then reconnected, and the existing element that was left in the DOM becomes the active view. This also allows for the scroll position of previous views to be maintained.

Caching can be disabled and enabled in multiple ways. By default, Ionic will cache a maximum of 10 views, and not only can this be configured, but apps can also explicitly state which views should and should not be cached.

Caching can be disabled per view by using cache: false in UI-router’s state config. The$ionicConfigProvider can be used to set the maximum allowable views which can be cached, but this can also be use to disable all caching by setting it to 0.
Learn More with Madanswer

Related questions

0 votes
asked Jul 24, 2020 in Ionic by Robindeniel
...