[keycloak-dev] need to cache REST calls
Bill Burke
bburke at redhat.com
Wed Aug 7 08:18:40 EDT 2013
I don't know. You can do this approach, but you'll still need "global"
variables to support ng-models which are shared across $scopes. Take a
look at the realm selection box in the admin UI. When you save a new
realm, the realm selection box is updated, and the selection is changed
to the realm you just created. Also note that for things like a
selection box, the ng-model has to point to objects stored in the
ng-options or it won't work.
On 8/7/2013 6:23 AM, Stian Thorgersen wrote:
> I've done an example of what I was thinking about when I talked about using the built in Angular cache for this:
>
> http://pastebin.com/RzucUmMP
>
> This way you don't need to put it in the rootScope, and you can have multiple controllers retrieving it without the extra hit. In the future Angular will support this internally by just adding "cache: true" when creating the $resource
>
> ----- Original Message -----
>> From: "Bill Burke" <bburke at redhat.com>
>> To: "Stian Thorgersen" <stian at redhat.com>
>> Cc: keycloak-dev at lists.jboss.org
>> Sent: Monday, 5 August, 2013 3:07:43 PM
>> Subject: Re: [keycloak-dev] need to cache REST calls
>>
>> 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
>>
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com
More information about the keycloak-dev
mailing list