[keycloak-dev] need to cache REST calls

Bill Burke bburke at redhat.com
Mon Aug 5 10:07:43 EDT 2013


Ya, thats how I currently do a global scope.  'Current' is a service.

module.controller('GlobalCtrl', function($scope, $http, Current) {
     $scope.current = Current;

 
$http.get('/auth-server/rest/saas/admin/realms').success(function(data) {
         Current.realms = data;
     });
});


A global scope allows you to link ng-model's across $scopes.

Again, (see previous email) if you rely on HTTP caching mechanisms, you 
won't get updated results i.e. a dropdown populated with a list of 
realms or resources that should be updated if a realm/resource/role/user 
is created/deleted.  Later on though to improve network performance, we 
could reduce HTTP response payload sizes, by forcing the browser to do 
conditional GETs by passing back ETag with GET responses.




On 8/5/2013 9:06 AM, Stian Thorgersen wrote:
> I don't think it's the correct approach to cache in controllers. It should be done in the service (angular). Also would it not be an idea to use the cache mechanism already provided by http? Alternatively it could use angulars built in cache mechanism (http://docs.angularjs.org/api/ng.$cacheFactory).
>
> ----- Original Message -----
>> From: "Bill Burke" <bburke at redhat.com>
>> To: keycloak-dev at lists.jboss.org
>> Sent: Monday, 5 August, 2013 1:49:50 PM
>> Subject: Re: [keycloak-dev] need to cache REST calls
>>
>> "require to down" == "request to download"
>>
>> On 8/5/2013 8:48 AM, Bill Burke wrote:
>>> IMO, the admin UI makes too many REST calls that will make the UI both
>>> slow and increase load on the backend.  We should fix this after the 1st
>>> iteration of the admin UI.  When the GlblCtrl initializes it should make
>>> one big REST require to down everything that makes sense in the first go
>>> and cache it in a global scope.  (i.e. everything but users and
>>> role/scope mappings). UI components should render and link their models
>>> to variables in the global scope.  I've already had to do this to make
>>> the realm-switching select box I added work in an integrated fashion.
>>>
>>
>> --
>> Bill Burke
>> JBoss, a division of Red Hat
>> http://bill.burkecentral.com
>> _______________________________________________
>> keycloak-dev mailing list
>> keycloak-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/keycloak-dev
>>

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com


More information about the keycloak-dev mailing list