We've been working with Telligent Community (Telligent Community) since the product was first launched as Community Server version 1. The product started as a lightweight combination of 3 applications combined into a basic platform and has evolved into an Enterprise platform that is used by some of the biggest brands in the world. Over this time we moved from .net 1 to to .net 4.5 and indeed versions of IIS have changed. The way the internet is presented has changed, pages are now much richer and contain more functionality, consequently the amount of page data and external files has increased.
Occasionally my technical abilities are allowed to be used in the company, not often enough I say! On this occasion I was learning more about the semantic web and how it is changing SEO and page rankings, there will be a post on this at a later date. For now suffice to say by researching and creating a plugin for the semantic web I started thinking about how we could improve the performance in Telligent Community . One of the techniques that sprang to mind was bundling, this is now a native feature of .net 4.5. Bundling is the process of aggregating and minification of files to reduce the amount of data being sent to the browser and also reduce the number of requests to IIS.
The next hurdle was to get to the page as it was rendered and then perform the required processing. The solution came in the form of the Microsoft Reactive Extensions and a new feature of .net 4.5. Using
PreApplicationStartMethod I was able to register a new module wrapped in a plugin. This plugin's responsibility is to hook into the rendering pipeline using a response filter to parse the document into CsQuery and then using Ms-RX to notify observers that a page is ready to be formatted. In order to speed up performance we used an updated version of the memory stream class that allocated fix memory blocks rather than using the standard MemoryStream class.
Now that I had a mechanism to read the page and update the markup I had to figure out how to update and identify which elements could be bundled. The Microsoft bundling code allows you to bundle files using 2 base classes ScriptBundle and StyleBundle. In a typical deployment these are populated and registered up front, unfortunately due to the dynamic nature of Telligent Community this is not possible, so I created a set of wrappers that understand how to parse the HTML to extract the links that can be bundled and also update the HTML to reference the bundle URL.
The StandardStyleBundle class is pretty simple, it extracts meta links that reference CSS in the page adds them to the bundle. Depending on the type of link it will use a particular bundle file handler. In the case of CFS and remote files these are copied to a local cache on the server. This prevents servers from getting out of sync with page layouts when in a web farm.
The StandardScriptBundle does the same as the StandardStyleBundle class, however it additionally handles web resource (axd) links and also widget files by enumerating over the widgets on the page to identify widget scripts.
The class diagram above describes the solution in a little more detail.
Here are some screenshots from the 4 roads site before and after:
We've decided that this plugin and some other future plugins are going to be released for free to all Telligent Community clients, we have versions for Telligent Community 6.0 upwards. If you would like to try out our plugin then please contact us and we will be happy to send it to you.