# Bust controller cache only when navigating from side menu

**URL:** <https://forum.ionicframework.com/t/bust-controller-cache-only-when-navigating-from-side-menu/57834>\
**Category:** ionic-v1\
**Created:** [July 18, 2016, 11:30am UTC](https://forum.ionicframework.com/t/bust-controller-cache-only-when-navigating-from-side-menu/57834 "2016-07-18T11:30:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lehresman](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/lehresman/32/73184_2.png) [@lehresman](https://forum.ionicframework.com/u/lehresman)\
**Post date:** [July 18, 2016, 11:30am UTC](https://forum.ionicframework.com/t/bust-controller-cache-only-when-navigating-from-side-menu/57834/1 "2016-07-18T11:30:22Z")

</div>

I’m looking for a way to bust the view cache only when navigating from the side menu.

I can’t use `cache-view="false"` in the template because that will totally disable caching (i.e. the controller will reload even when going “back” from deeper in the navigation stack).

I can’t disable caching globally, again for the same reason as above.

I can’t use `ui-sref-opts="{reload:true}"` because Ionic seems to ignore that and perform its own caching anyway.

I can’t seem to use `$ionicView.enter` or `$ionicView.beforeEnter` view lifecycle events because those are triggered even when you navigate _back_ to the view.

My use case is that one of my side-menu navigation items is a calendar. I want it to always reset to “today” when you tap on the side menu entry, but you may have navigated to a different month then drilled down further. When you go back, it should stay on the month you selected. It should only reset when navigating from the side menu.

Unfortunately I have not been able to discover a way to detect this scenario.

Thanks for your help!  
Luke

---

<div class="post-metadata">

**Author:** ![Moltar](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/moltar/32/101009_2.png) [@Moltar](https://forum.ionicframework.com/u/Moltar)\
**Post date:** [July 19, 2016, 3:28pm UTC](https://forum.ionicframework.com/t/bust-controller-cache-only-when-navigating-from-side-menu/57834/2 "2016-07-19T15:28:29Z")

</div>

Could you include a parameter within state that can be passed inside the link that will reset the state back to original? This isn’t a cache invalidation per se, just your own code setting up things as needed. You can do that inside `$ionicView.beforeEnter` event handler.

---

<div class="post-metadata">

**Author:** ![lehresman](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/lehresman/32/73184_2.png) [@lehresman](https://forum.ionicframework.com/u/lehresman)\
**Post date:** [July 25, 2016, 6:18pm UTC](https://forum.ionicframework.com/t/bust-controller-cache-only-when-navigating-from-side-menu/57834/3 "2016-07-25T18:18:03Z")

</div>

That would be great, but I still can’t figure out how to detect the difference between `$ionicView.beforeEnter` getting triggered from a “back” action, and when a side-menu option is chosen.

The state is identical in both cases.

---

<div class="post-metadata">

**Author:** ![lehresman](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/lehresman/32/73184_2.png) [@lehresman](https://forum.ionicframework.com/u/lehresman)\
**Post date:** [July 25, 2016, 7:09pm UTC](https://forum.ionicframework.com/t/bust-controller-cache-only-when-navigating-from-side-menu/57834/4 "2016-07-25T19:09:30Z")

</div>

For posterity, I figured out a hack around this problem.

```auto
    $scope.$on('$ionicView.beforeEnter', function() {
      if (!$ionicHistory.viewHistory().forwardView) {
        reload();
      }
    });

```
