# Non desired caching for forward view

**URL:** <https://forum.ionicframework.com/t/non-desired-caching-for-forward-view/29207>\
**Category:** ionic-v1\
**Created:** [July 25, 2015, 10:07pm UTC](https://forum.ionicframework.com/t/non-desired-caching-for-forward-view/29207 "2015-07-25T22:07:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![eladhayun](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/eladhayun/32/13748_2.png) [@eladhayun](https://forum.ionicframework.com/u/eladhayun)\
**Post date:** [July 25, 2015, 10:07pm UTC](https://forum.ionicframework.com/t/non-desired-caching-for-forward-view/29207/1 "2015-07-25T22:07:15Z")

</div>

Hello,  
i’ve been trying to find a solution to my problem,  
I am working on an app that uses the tabs template, one of the tabs has three views inside it  
So suppose i’m on Tab1, View1, navigating to View2, filing data in it, and navigating back to View1 and View2 again, the data will be purged (DOM elements are cleared as expected and scope is reconnected to watch cycle as expected), however, going from View1 --\> View2 (fill data) --\> View3 --\> View1 --\> View2 again, data is not purged !!

is there a way to fix this behaviour ? should i explicitly tell View3 that after entering View1, reset history or similar?

THANKS!!

---

<div class="post-metadata">

**Author:** ![robinyo](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/robinyo/32/115964_2.png) [@robinyo](https://forum.ionicframework.com/u/robinyo)\
**Post date:** [July 27, 2015, 2:17am UTC](https://forum.ionicframework.com/t/non-desired-caching-for-forward-view/29207/2 "2015-07-27T02:17:31Z")

</div>

```
// By default, views are cached to improve performance.
// Set $ionicConfigProvider.views.maxCache(0); to disable cache globally
// See: http://ionicframework.com/docs/api/directive/ionNavView/

```

or on a case by case (cache: false) basis:

```
.state('app.main', {
        url: '/main',
        cache: false,
        views: {
          'menuContent': {
            templateUrl: 'templates/main-template.html',
            controller: 'MainController',
            resolve: {
              posts: function(PostsService) {
                return PostsService.findPosts();
              }
            }
          }
        }
      })
```

---

<div class="post-metadata">

**Author:** ![eladhayun](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/eladhayun/32/13748_2.png) [@eladhayun](https://forum.ionicframework.com/u/eladhayun)\
**Post date:** [July 27, 2015, 5:53am UTC](https://forum.ionicframework.com/t/non-desired-caching-for-forward-view/29207/3 "2015-07-27T05:53:10Z")

</div>

Thanks for your reply, i am aware of the possibility to disable cache, either on a global or local scope,

the thing is, if i disable the cache for View2, going back from View3 to View2, removes the data from the view… i would like to be able to persist the data as long as i haven’t closed a complete flow,  
meaning, persist data on View1 --\> View2 --\> View3 , but if i moved out View3 (excluding going back to View2), clear cache and remove data…

Is that possible?

---

<div class="post-metadata">

**Author:** ![robinyo](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/robinyo/32/115964_2.png) [@robinyo](https://forum.ionicframework.com/u/robinyo)\
**Post date:** [July 27, 2015, 5:58am UTC](https://forum.ionicframework.com/t/non-desired-caching-for-forward-view/29207/4 "2015-07-27T05:58:28Z")

</div>

How have you defined them?

Are they nested states?

Do you have a Plunker?

> **[angular-ui/ui-router](https://github.com/angular-ui/ui-router/wiki/Nested-States-and-Nested-Views)**
>
> ui-router - The de-facto solution to flexible routing with nested views in AngularJS

---

<div class="post-metadata">

**Author:** ![eladhayun](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/eladhayun/32/13748_2.png) [@eladhayun](https://forum.ionicframework.com/u/eladhayun)\
**Post date:** [August 20, 2015, 7:17am UTC](https://forum.ionicframework.com/t/non-desired-caching-for-forward-view/29207/5 "2015-08-20T07:17:29Z")

</div>

Seems like solution was easy enough, i used $ionicHistory.clearCache()
