Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Optimize the View State
To examine a Visualforce page’s view state, set the Development Mode and the Show View State in Development Mode user permissions. The View State tab in the development mode footer displays the distribution of the view state. Make sure you know the view state size of each page, and test with large data volumes to prevent issues that can occur after deployment.
To reduce the view state:
- Use filters and pagination to reduce data that requires state.
- Declare an instance variable with a transient keyword if the variable is only useful for the current request. A transient variable isn’t included in the view state.
- Refine your SOQL calls to return only data that's relevant to the Visualforce page.
- Reduce the number of components that your page depends on.
- Make data read-only. Use the <apex:outputText> component instead of the <apex:inputField> component.
- Use JavaScript remoting. Unlike the <apex:actionFunction> component, JavaScript remoting doesn’t require an <apex:form> component. JavaScript remoting doesn’t reduce the overall view state of a page, but your page generally performs better without the need to transmit, serialize, and deserialize the view state. The tradeoffs are the loss of the reRender attribute and the necessity of additional JavaScript code to handle callbacks.