Visualforce pages that contain a form component also contain an encrypted, hidden form field that encapsulates the view state of the page. This view state is automatically created, and as its name suggests, it holds the state of the page – state that includes the components, field values and controller state.
Below is some tips to improve the performance of you Visualforce pages:
Minimize Number of Form tags between apex:page
A Visualforce page manages a single view state, even when the page contains multiple input forms (<apex:form>). Instead of having multiple forms on a page, have a single form and use <apex:actionRegion> to submit portions of the form. The reason is when multiple forms are present in a single page the view state will be retrieved all forms when an action submits. This means the current form may run slower if the other forms have a large view state. <apex:page controller="UpdateAccountContactController"> <apex:form> <apex:commandButton action="{!saveAccount}" value="Update Account"/> <apex:actionRegion> <apex:commandButton action="{!saveContacts}" value="Update Contacts"/> <!--Contact attributes available for editing --> </apex:actionRegion> </apex:form> </apex:page>
Order of Postback Request in Visualforce page:
http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_postback_request.htm
Check out the execution order of an Visualforce page:
http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_lifecycle_example.htm
Other things to consider to decrease the size of your view state
- Use transient keyword
- Optimize SOQL queries and use Custom Objects to store large quantity data
- Implement Visualforce Remoting
- Use Streaming API