{ cloud ☁️ architect }

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: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>