Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove caching completely in Ionic

I have an app that reads the latest posts from my Wordpress website and displays it in a list. The problem is every time the user reopens the app it loads an old (cached) list of articles even though there are new posts on my website.

I've been through it all in terms of disabling caching in ionic:

I've set $ionicConfigProvider.views.maxCache(0);

My template's first line is this: <ion-view class="home-view" cache-view="false">

Tried setting cache: false in .state('app.home')

Tried loading a state like this: $state.go('app.home', {}, {reload : true}); Did not work as expected.

Tried clearing the cache like this on resume: $ionicHistory.clearHistory(); $ionicHistory.clearCache();

Even tried stuff like $route.reload and $window.location.reload on resume but it's not working.

None of them work. I'm at the end of my rope here!

Please help!

like image 694
Ako Avatar asked Aug 14 '15 04:08

Ako


1 Answers

What I finally ended up doing was to load the pull to refresh's function on beforeEnter like this:

$scope.$on('$ionicView.beforeEnter', function () {
    $scope.doRefresh();
});

You never know, it might help someone else who finds themselves in the same situation as me :)

like image 150
Ako Avatar answered Nov 10 '22 16:11

Ako