Visualforce View State Performance Tuning

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:commandButton action="{!saveAccount}" value="Update Account"/>

       <apex:commandButton action="{!saveContacts}" value="Update Contacts"/>
     <!--Contact attributes available for editing -->


Order of Postback Request in Visualforce page:
Check out the execution order of an Visualforce page:

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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s