Newer Version Available
Foreground and Background Actions
When enqueued actions are grouped into boxcars and sent to the server, foreground actions are processed first, followed by background actions. Don’t rely on each background action being sent in its own request as that behavior isn’t guaranteed. On the server, foreground actions run in parallel with background actions, and responses for foreground and background actions can come back in either order.
Framework-Managed Request Throttling
The framework manages and enqueues foreground and background requests separately. This means that the framework can control the number of foreground requests and the number of background actions running at any time. The framework automatically throttles the rate of sending these requests. Other than setting an action to run in the background, you can’t control the framework’s request processing. The framework manages the number of foreground and background XHRs, which varies depending on available resources and the boxcar’ing strategy enabled in your org.
Even with separate throttling, background actions can affect performance in some conditions, such as when there is an excessive number of requests to the server.
Setting Background Actions
To set an action as a background action, call the setBackground() method on the action object in JavaScript.
1// create a server-side action
2var action = cmp.get("c.serverEcho");
3
4// optionally set actions params
5// action.setParams({ firstName : cmp.get("v.firstName") });
6
7// set as a background action
8action.setBackground();