Server-side $resource pagination versus client-side limitTo for large AngularJS datasets
0 reputation · 20 Apr 2023, 05:54 UTC
Goal: Bound a query and paginate a large dataset in an AngularJS 1.x application, which has no built-in pagination service.
Constraint: AngularJS does not prescribe server-side or client-side paging. Server-side paging through $http or $resource sends page/size or offset/limit parameters, keeping browser memory low but requiring backend endpoints and a network round trip per page. Client-side paging loads the full collection once and applies the limitTo filter, available since AngularJS 1.2, avoiding extra requests but increasing initial payload and digest-scope cost.
Unresolved decision: whether to bound the query at the server before transfer or bound the view after transferring everything. Client-side limitTo on very large arrays can slow digest cycles, while server-side paging requires consistent backend sorting and filtering contracts.
Questions:
- Should the initial request return only the requested page, or should the client load the full dataset and apply limitTo?
- How should the backend expose a total count for UI pagination controls when using $resource?
- At what row count does client-side digest cost outweigh server round-trip latency?