# Ionic Clear Cache

**URL:** <https://forum.ionicframework.com/t/ionic-clear-cache/58279>\
**Category:** ionic-v1\
**Created:** [July 22, 2016, 8:01am UTC](https://forum.ionicframework.com/t/ionic-clear-cache/58279 "2016-07-22T08:01:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anicacute09](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/anicacute09/32/113162_2.png) [@anicacute09](https://forum.ionicframework.com/u/anicacute09)\
**Post date:** [July 22, 2016, 8:01am UTC](https://forum.ionicframework.com/t/ionic-clear-cache/58279/1 "2016-07-22T08:01:06Z")

</div>

Hi guys, I have a button that whenever i Logout and returns to Login View it clear all the cache… now I was facing a problem as I Login for the first time and Logout immediately, It doesn’t clear the cache of Login view and as I repeat to login again and logout… the function works now… What would be the best solution here?

.controller(‘LoungeCtrl’, function ($scope, $state, $ionicHistory, Data) {

```
$scope.logout = function () {
        $ionicHistory.clearCache();
        $ionicHistory.clearHistory();
        $state.go('index');
};

```

})
