I am creating an application using AngularJS framework.
The Problem:
When I jump out of my application to a different domain or a page and then when I use history back button to get back to my app, I get back only JSON. The same situation happens when I jump out of my app browsing back in history, and then when I use forward button to go to my app, again I get only JSON back. Back/forward works fine within my app, it happens only when I go to different domain.
Why is that? I think it is related to caching some how, because when I do back/forward to my app, no request is send to the server.
You can see what I'm talking about if you go to this url - http://test.deving.cz/admin/prihlasit/. Then go back and then forward.
My setup:
My app is configured to use HTML5 history API. For an url that starts mydomain.com/admin/ I always return an index.hmtl containing angular. Then for every other url in my app two requests are send out. One for the template and one for the data (the JSON).
Example:
$routeProvider.when('/admin/page/', {controller: 'PageListCtrl', templateUrl: '/templates/page/list/', resolve: 'PageListCtrl.resolve'})
PageListCtrl:
angular.module('page').controller('PageListCtrl', ['$scope', 'data', function($scope, data) {
$scope.pages = data;
}]);
Resolve function:
resolve = {data:
function($http, $q){
var delay = $q.defer();
$http.get().success(function(data){
delay.resolve(data['data']);
});
return delay.promise;
}
}
How should I configure angular or my app to tell the browser not to cache the data and to always get the index.html and then let angular do the requests?