amazon-s3ionic-frameworkmulti-device-hybrid-apps

Clear all cache in ionic app


I am doing an ionic app and I have a profile picture saved in amazon s3. I have an input type file, to change that picture. Everything works fine but the problem is that although the picture changes in amazon, in the view it doesn't change. I cleared the cache like this:

$scope.$on("$ionicView.enter", function(event, data)
    {
        $timeout(function(){
            $ionicHistory.clearCache();
        });

and in my app.js I have this as well:

.state('app.settings', {
    cache: false,
    url: '/settings',
    views: {
      'menuContent': {
        templateUrl: 'templates/settings.html',
        controller: 'SettingsCtrl'
      }
    }
  })

But the last picture appears instead the new one.

Thanks!


Solution

  • While loading the image form Amazon Service use versioning such as.

    http://amazonlink.com/yourImage?version=4
    

    Each http call which is same is previous is cached often to improve the perfomance. If you change the version number at the end each time the image is loaded, it forces the request and load the new image. Hope this helps.