1

Is there a way to achieve Empty cache and hard reload of browser using angularjs or javascript programmatically.

I am not talking about clearing the cache of angularjs application but the browsers using angularjs

Empty cache and hard reset

Sunil Lama
  • 4,531
  • 1
  • 18
  • 46
  • set `no-cache` header on server side where your application hosted.. – Pankaj Parkar Feb 15 '16 at 12:26
  • i was wondering if there was a work around on the client side. – Sunil Lama Feb 15 '16 at 12:33
  • 1
    This is possible duplicate of http://stackoverflow.com/questions/31850824/angularjs-force-browser-to-clear-cache (altough it doesn't have an answer at this moment in time) – Jim Aho Feb 15 '16 at 12:47
  • clearing cache in angularjs application is onething, however i am talking about the whole browser empty cache and hard reload feature via angularjs, hope this clears the misunderstanding. – Sunil Lama Feb 15 '16 at 12:49
  • this also discuss this topic: http://stackoverflow.com/questions/1922910/force-browser-to-clear-cache – iCediCe Oct 28 '16 at 08:44

1 Answers1

2

inject $templateCache in your main controller and execute once function X

(function () {
  'use strict';
  angular.module('app.module.core').controller('LayoutCtrl', LayoutCtrl);
  LayoutCtrl.$inject = ['$rootScope', '$scope', '$http', '$templateCache', '$cacheFactory'];

  function LayoutCtrl($scope, $rootScope, $http,$templateCache, $cacheFactory) {

$scope.clearCache = function (){
        setTimeout(function() {
          $templateCache.removeAll();
               }, 5000);
 }()
mQuiroz
  • 1,339
  • 13
  • 11