I noticed everytime I use action function it returns the whole page including the viewstate. Why the response has the url to css and javascript files? Is there anyway to limit the size of ajax response when you are using actionfunction?

  • Do you have a "rerender" on your actionFunction? Sep 14 '13 at 1:13

There are two types of Visualforce page requests:

  • A get request is an initial request for a page either made when a user enters an URL or when a link or button is clicked that takes the user to a new page.
  • A postback request is made when user interaction requires a page update, such as when a user clicks on a Save button and triggers a save action.

Addt'l info here: http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_lifecycle_example.htm

Using an actionFunction with rerender attribute will cause a postback request to the controller, thus the Visualforce Viewstate will need to go back to the controller and de-serialize so that the instance of the controller is validated against the page state.

If your actionFunction is rerendering something that is a very large static and is not transient, you should rethink your controller design a bit. If there are instance members that are not being actively accessed on your page, but just used or rendered conditionally, you can make them transient. This would reduce your viewstate payload considerably. Try not to throw List<>, Array[], or Map<> collections at your page unless you have to.


One of the major reason of loading an entire page is using <apex:form> covering the entire page. You may be using a single <apex:form> for all action functions, command button or command link.

Page viewstate is related to <apex:form> if your form reloads then viewstate will be reload with it.

Try to use multiple <apex:form> for larger pages and exclude all unwanted information which should not be in between <apex:form> tag. All information between from is part of view state.

As in your page all javascript files, css are loading because either you are rendering a area on your page which include these files or your form has these file in between.

  • I see your point about apex:form. I guess I can use apex:actionregion to split the action, then. As about the css and js files, not that case. I even have salesforce js included into the ajax response, too. Sep 15 '13 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.