Wednesday, January 30, 2013

Introduction to the Minimal Download Strategy (MDS)

Continuing the posts about the new improvements in SharePoint 2013 I can't avoid to write about the Minimal Download Strategy, for the friend MDS.


SharePoint is based on ASP.NET Web Form and, as you know, this technology is based on a request-response approach whether you need to update the whole page or a portion of it, and a determinate Page Life Cycle will be start for any request from the client.
The following illustration shows some of the most important methods of the Page class:
If you like, you can find more information in the following link:
In the last years, to avoid to reload whole information on the page, we’ve seen smart approaches using DHTML, JavaScript, AJAX, UpdatePanels, and so on. Off course this solution are focused to make a better UX and minimizing the amount of data downloaded for each user interaction and increase the performance.
Even though SharePoint did some improvements in this way, many times when a user interacted with a page, the entire page was downloaded to the client computer.
SharePoint 2013 is based on a very rich web interface that contains lots of moving parts and lots of customizable areas, maintain this approach would be disruptive.
For this reason, SharePoint 2013, comes with a new navigation framework that improves page load performance by only downloading those portions of the page that have changed. This is known as the Minimal Download Strategy.

How does it works?

It works with the AjaxDelta control that should be added to the head section of master pages. By default, the MDS feature is activated on the Team, Community, Wiki, Projects, App, and Blog site templates.
When the site uses MDS and a page is requested, the address bar of the browser displays a URL like this: http://address.domain/_layouts/15/start.aspx#/SitePages/Home.aspx
The start.aspx is responsible for loading pages, it contains a JavaScript object asyncDeltaMaganer defined in start.js file. Basically it parses the URL, looks for the sign #. Only the changed portions are downloaded to the client’s if the requested page contain the querystring parameter AjaxDelta=1.
The key class that is responsible to generate the full pages or just the deltas is the DeltaPage. The common pages are inheriting from this. When MDS is enabled it is responsible for creating the delta response and for handling exceptions.
There is also a control called PageRenderMode that can be used on a master page, web part page or page layout. This control accepts two values, Standard or MinimalDownload. If it is not presente or if it’s property is set to MinimalDownload it can participate in MDS rendering:
<SharePoint:PageRenderMode runat="server" RenderModeType="MinimalDownload" />

Custom control

You are able to make your own control (web parts, pages, etc.) that use MDS. There is the attribute MdsCompilantAttribute that you can set on a class of your control:


 you can add the attribute to the assembly too, in this way all of your classes will use MDS.

No comments:

Post a Comment