This topic will discuss how to improve performance by managed WebGrid's caching, Client performance, Server performance and AJAX performance using WebGrid.NET Designer.
Caching
WebGrid.NET control includes automatic data caching feature to help reducing database workload. When enabled, a copy of datasource per user session will be stored in cache. As long as the cache is still valid and active, WebGrid will use the cached data for all data-aware functions, including during AJAX callback and full page postback.
Please note that this feature does not take into affect when the WebGrid is bound to DataSourceControl because DatasourceControl already has its own Caching mechanism and is more sophisticated. This feature is designed to traditional datasouce binding (eg. via InitializeDataSource event)
- Data Cache Storage. Specifies a location that hold the temporary data cache.
- Page Cache.
This is a good option to cache relatively small datasource.
The cache is oftenly cleared when the system needs more memory resource. - Session
Store data cache to ASP.NET Session.
This is a good option to store user-specified datasource. Session is also recommended when you need data to remain cached as long as the user's session is active . - File Server
Store data cache to physical disk, usually file server.
This is a preferrence when you need to cache relatively large data source in a long time span.
Please note that this option may be slower than in-memory storage.
If you have set Data Cache to File Server, you must specify FileServer Connection. Example "C:\CacheStorage". Note that you need to set read and write permission for the worker process to access the specified path
- Use cached data on first load. This is an advanced setting and should be set to false in common scenarios.
If you set this setting to True, then when first load WebGrid will find whether there is a cached data or not. If there is a cached data, then WebGrid's data will be loaded base on the cached data.
Performance Tuning
Performance tuning in WebGrid can be grouped into 3 categories.
-
Client performance.
The tuning significantly reduces page output size which results in faster page response- Enable default style feature.
When default style is enabled, WebGrid does not generate individual control style in the rendered page. This results in significantly reduced page size, especially when there are lot of WebGrid instances in the page - Use WebStyleManager to apply theme globally into entire application.
WebStyleManager is a great way for applying global theme to entire application. WebStyleManager allows you to use custom styles with high page performance by generating the styles into external stylesheet.
To learn more about WebStyleManager, please refer to WebDesktop.NET documentation, and read the concepts under WebStyleManager's topic.
- Enable default style feature.
-
Server performance.
You can gain better page throughput and performance by using appropriate Cache configuration and ViewState setting.
- Reduce database workload by caching frequently used data.
Appropriate utilization of built-in data cache feature in WebGrid.NET can help in delivering better response and page performance in overall. -
Determine best ViewStateStorage configuration-set for this control.
- ViewState Storage
- None
- PageCache
- Session
- FileServer
- ViewState Item.
- Behavior
- BehaviorAndCollection
- BehaviorAndStyle
- All
- ViewState FileServer Connection.
If you choose FileServer option for ViewStateStorage, you need to set the FileServer Connection.
Example : "C:\CacheStorage".
Note that you need to set read and write permission for the worker process to access the specified path
- ViewState Storage
- Reduce database workload by caching frequently used data.
- AJAX performance (Advanced).
By properly configuring the following settings, you can significantly improve AJAX's callback performance. These settings are applicable only in DataBound mode usage.
- Post control state.
When set to true, the control state is submitted during AJAX call.
If you set the control's properties in design-time to repopulate during postback, you can set this option to False. - Post hidden fields.
When set to True, the hidden fields in this page are submitted along the AJAX call.
If you do need to access hidden fields in WebGrid events, you can generally set this option to False - Post INPUT controls.
When set to True, the INPUT controls such as textbox, radio button, check box and other html input controls are submitted along the AJAX call.
If you do not access these controls (or you do not need to obtain the values of these controls), you can set this option to False - Post view state.
When set to true, the viewstate of the page is submitted along the AJAX call.
If you do not need to access or interact with other controls in the page during WebGrid's AJAX events, you can set this option to False
Other Resources
Miscellaneous WebGrid Settings
Walkthrough Topics
How-to Topics