Software Development - DHTML - RoboProg's

RoboProg's / Software Development

Last Month


Aug 29, 2011

Scaling with DHTML and Ajax.

I recently had a discussion with a coworker about a project he was starting. What he wanted to do was more tuned to an intranet project, but it got me thinking about how a web site could be radically structured, albeit with some work, to greatly enhance scalability by exploiting caching and client-side rendering.

The goal would be to seperate as much of the HTML and other artwork as possible into immutable files which can be cached within the browser or other intermediate layers. Also, we want to get the server out of the business of rendering complex pages -- the assembly of condensed data with HTML layout would be done on the client side. Finally, by removing input data from HTML output, and instead providing it within a strictly encoded format, we can hopefully minimize our vulnerability to cross site scripting by using a small carefully designed library to place the data on the page in a properly encoded display format.

Such an approach might split a typical application page into 4 parts as follows:

  1. A minimal page which loads needed JavaScript libraries, and which contains "key" information for REST requests. This first / top level page contains variable content, and is kept as small as possible.
  2. One or more JavaScript library files, which can be cached.
  3. A fixed template page with no variable data, which can be cached.
  4. Document requests (JSON, XML, YAML) containing the data from which the DHTML for a page will be generated, using the static HTML as a template

This of course ignores any required CSS and graphics files, which continue to be used as needed.

I have ignored possible use of XSLT for several reasons, but you are of course welcome to do whatever suits your expertise and preferences. In going this route, I would probably use JSON to transmit the data, as it is less verbose and bandwidth consuming than XML. Of course, once you have the JSON converted to a JavaScript object, rather than used as input for an XML SAX or DOM parser, it then makes more sense to me to just use JavaScript with a DHTML library to fill in the final page, rather than XSLT to generate XHTML.

TODO: provide an example mockup (some other day).


("month"? Who am I kidding...)


Contact me:
r
o
b
o
p
r
o
g
@
yahoo.com

Copyright 2011, Robin R Anderson