# Issue with view caching

**URL:** <https://forum.ionicframework.com/t/issue-with-view-caching/15273>\
**Category:** ionic-v1\
**Created:** [January 8, 2015, 1:05am UTC](https://forum.ionicframework.com/t/issue-with-view-caching/15273 "2015-01-08T01:05:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sreekanth](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sreekanth/32/67832_2.png) [@sreekanth](https://forum.ionicframework.com/u/sreekanth)\
**Post date:** [January 8, 2015, 1:05am UTC](https://forum.ionicframework.com/t/issue-with-view-caching/15273/1 "2015-01-08T01:05:53Z")

</div>

Hi,

I’m having an issue with the view cache. Not sure if i’m doing it wrong or it’s an issue with Ionic.

In ‘add grocery’ view, initially there are 2 groceries, pull down to fetch more groceries. It shows additional groceries appended to the list. Now, go back and visit ‘add grocery’ view again.

If view caching is enabled (by default, it is), then i should be seeing more than 2 groceries in the list, however, i see only 2 groceries. Am I missing something here?

[http://embed.plnkr.co/vUlbDf3c4ywP5g3F8sWs/preview](http://embed.plnkr.co/vUlbDf3c4ywP5g3F8sWs/preview)

Appreciate your help.  
Sreekanth

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [January 8, 2015, 8:42pm UTC](https://forum.ionicframework.com/t/issue-with-view-caching/15273/2 "2015-01-08T20:42:43Z")

</div>

Nope, no issue here, this is by default.

> By default, when navigating, views that were recently visited are cached, and the same instance data and DOM elements are referenced when navigating back. However, when navigating back in the history, the “forward” views are removed from the cache. If you navigate forward to the same view again, it’ll create a new DOM element and controller instance. Basically, any forward views are reset each time. Set this config to true to have forward views cached and not reset on each load.

You can enable this by adding this config option.

```javascript
 $ionicConfigProvider.views.forwardCache(true);

```

> **[$ionicConfigProvider - Provider in module ionic - Ionic Framework](https://ionicframework.com/docs/v1/api/provider/$ionicConfigProvider/)**
>
> Ionic makes it incredibly easy to build beautiful and interactive mobile apps using HTML5 and Angular.

> **[Plunker - Untitled](https://plnkr.co/edit/9RrxEuYFZ95TZVy2A95m?p=preview)**
>
> Created on https://plnkr.co: Helping you build the web.

---

<div class="post-metadata">

**Author:** ![sreekanth](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sreekanth/32/67832_2.png) [@sreekanth](https://forum.ionicframework.com/u/sreekanth)\
**Post date:** [January 9, 2015, 2:20am UTC](https://forum.ionicframework.com/t/issue-with-view-caching/15273/3 "2015-01-09T02:20:59Z")

</div>

@mhartington Ah, I missed that one. Thank you for clarifying it.

Another thing, in ‘browse’ view (use sidemenu to go this view), when tapped on ‘go to shopping list’ button, it does $state.go(‘app.shoppinglist’), so view/state transitions to ‘shopping list’ view correctly, but there, it displays ‘back’ nav button at the top. I would not want to see the back button, just like in the case when ‘browse’ menu item is tapped in the side menu, it doesn’t show any ‘back’ button.

Why is it showing ‘back button’? How do I fix it?

Thanks again  
Sreekanth

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [January 9, 2015, 3:14pm UTC](https://forum.ionicframework.com/t/issue-with-view-caching/15273/4 "2015-01-09T15:14:53Z")

</div>

You can use `$ionicHistory` for this.

> **[Plunker](http://plnkr.co/edit/fMX1zJbELQd1fCDpj8cf?p=preview)**
>
> Created on Plnkr: Helping developers build the web.

```auto
$ionicHistory.nextViewOptions({
     disableAnimate: false,
     disableBack: true,
     historyRoot: true
});

```

---

<div class="post-metadata">

**Author:** ![sreekanth](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sreekanth/32/67832_2.png) [@sreekanth](https://forum.ionicframework.com/u/sreekanth)\
**Post date:** [January 10, 2015, 6:18am UTC](https://forum.ionicframework.com/t/issue-with-view-caching/15273/6 "2015-01-10T06:18:27Z")

</div>

Thanks @mhartington . That fixes my issue.
