0

This is something that's been bothering me.

In a typical web application, request goes to the server and the server does it's 'stuff' and returns the template along with the data, ready to be displayed on the browser.

In Angular however, there is a response to get the template and, in most cases, another one to get the data.

Doesn't this add pressure on the bandwidth – 2 responses sent over the wire as compared to one from a typical web app. Doesn't it also imply a (possibly) higher page-load time?

Thanks, Arun

Arun
  • 1,015
  • 1
  • 11
  • 26
  • May be my post will be relevant, have a look: http://stackoverflow.com/questions/18097923/angularjs-getting-data-inserted-in-a-dom – Ivan Chernykh Aug 15 '13 at 10:31
  • 1
    If you architect your application as single page app with routes managed at the client side, you can refresh same "page" multiple times, while the template will be loaded only once. In traditional scenario template would have to be fetched and parsed at the server multiple times. – package Aug 15 '13 at 10:33

1 Answers1

1

The short answer is that it depends. :)

For example, in terms of bandwidth, it depends on how big the 'server-side' view render payload is. If the payload is very big, then separating out the calls might reduce bandwidth. This is because the JSON payload might be lighter (less angle brackets) so the overall bandwidth could reduce. Also, many apps that use ajax are already making more than one call (for partial views etc).

As for performance, you should test it in your application. There is an advantage to calling twice if you are composing services and one service might take longer than another. For example, if you need to layout a product and the service which provides 'number in the warehouse' takes longer than the product details. Then, the application could see a perceived performance gain. In the server-side view render model, you would have to wait for all the service calls to finish before returning a rendered view.

Further, client side view rendering will reduce the CPU burden on the server, because view rendering will be distributed on each client's machine. This could make a very big difference in the number of concurrent users and application can handle.

Hope this helps.

Davin Tryon
  • 66,517
  • 15
  • 143
  • 132