Visualforce Response Size Exceeded

I’ve a Visualforce page that holds a large amount of data.

I’ve used <apex:page readOnly="true"> to avoid the viewstate limit of 135 KB. However, I use a lot of data binding that makes the viewstate heavy.

I’ve recently hit a new limit “Response Size of 15 MB”. I believe this is the response size I get from page onload i the process of “Apex ->HTML conversion”.

Any suggestion on how to proceed will help. I’m trying to reduce the binding but still looking if there are other options available which I’m not aware of.

Visualforce Error

Answer

This error relates to the size of the HTML being produced by your Visualforce page and transmitted to the client browser. It is documented here.

The maximum response size from a Visualforce page request must be below 15 MB.

Reducing the bindings in your page will not improve this, unless it is reducing the HTML content your page is outputting. Though its always good to keep bindings simple when doing repeated output.

  • HTML elements vs VF elements. Study the HTML page DOM of the page once loaded (with less data) to see if your outputting any unnecessary HTML tags. Keep in mind the VF components output a lot of HTML tags, so consider what value in a read-only / report use case these are adding. Maybe best to use direct bindings to your state with regular HTML elements, e.g. < span >{!MyData}< /span >, < table > etc instead of the VF components. Although your not hitting a view state issue, this answer also goes into a little more detail on using HTML vs VF components and the benifits, How to reduce a large internal view state / what is in the internal view state?.
  • Inline Style Usage. If your using some styling on HTML elements your repeating often, you can put these at the top of the page in a style element or in separate CSS file.
  • Dynamic Loading. You might also want to consider using JavaScript to perform some client rendering and maybe build your content up dynamically (an advanced option is to load the data as the user scrolls).
  • Pagination. Depending on your requirements for this page (report vs interactive browse), you may also want to consider using a StandardSetController or custom pagination implementation to let the user page through the data, much like the Salesforce List View UI.

This is by no means an exhaustive list, there are a few other options to be considered around the types of those above, it kind of depends on what design goals are for the page you’re outputting. Hope this helps!

Attribution
Source : Link , Question Author : Vignesh Damodharan , Answer Author : Community

Leave a Comment