Network client optimization

A method of rendering an optimized web page or other resource includes requesting a resource and receiving a response including a user interface control declaration and a data array containing properties for the user interface control. The data array is parsed to produce a first property value, and a property of the user interface control is modified to correspond to the first property value. Alternatively, the response may not include a user interface control declaration, but a user interface control may be instantiated having a property that corresponds to the first property value. The property value may have been determined dynamically based at least in part on information provided with the request.

RELATED APPLICATIONS

The following co-pending patent applications, filed on date even herewith, are hereby incorporated by reference for all purposes:1. Ser. No 12/944,340, entitled “Web Application Optimization” by Daniel L. Bannoura and Gyorgy Bozoki.2. Ser. No. 12/944,365, entitled “Optimization of Compiled Control Objects” by Daniel L. Bannoura, Gyorgi Bozoki and Justin Collins.

BACKGROUND

The World Wide Web provides a convenient platform for sharing information. Among the many services offered through web sites are banking, shopping, and e-mail. In order to provide better services, many companies now provide customized web pages to each visitor. The customizations include examples such as providing a weather report based on a visitor's location, selecting targeted advertisements, and providing access to a visitor's account with the web site. Because each web page sent to a visitor is customized, the web server hosting the web site must create each customized page on demand, as it is requested by a visitor. Thus, providing customized web pages can put a strain on the processing resources of the web server. The increasing popularity of web pages also increases the traffic load on network resources that send and receive web pages.

SUMMARY

In one embodiment, a method includes requesting a resource and receiving a response including a user interface control declaration and a data array containing properties for the user interface control. The data array is parsed to produce a first property value, and a property of the user interface control is modified to correspond to the first property value.

In another embodiment, a method includes requesting a resource and receiving a response including a data element that includes a set of properties for a user interface control. The data element is parsed to produce a property value, and a user interface control is instantiated having a property that corresponds to the property value.

DETAILED DESCRIPTION

The present disclosure relates generally to the world wide web and a method of improving web pages and web-based applications. It is understood, however, that the following disclosure provides many different embodiments, or examples, for implementing different features of the invention. Specific examples of components and arrangements are described below to simplify the present disclosure. These are, of course, merely examples and are not intended to be limiting.

Referring toFIG. 1, illustrated is system100for implementing web page optimization technology. The system includes a server computer102that provides access to a web application by producing and transmitting documents such as web pages. The server computer102may execute web server software that receives web page requests and responds to the requests by transmitting web pages. Example web server software includes Internet Information Server available from Microsoft and Apache available from the Apache Software Foundation. In responding to requests, the web server software selects a source file that is used to produce the requested web page. The source file may be a web page or web page template file. The source file may include executable or interpretable code, and it may refer to a separate file containing executable or interpretable code. In some embodiments, the code may access data stored in a database108. The database108may be a SQL database, a file system, a graph database, or any other suitable database. Example database software includes Microsoft SQL Server, Oracle Database, and PostgreSQL. The database108may be located on the server computer102, on another computer, or on group of computers. The web server software executes portions of the code and sends the produced web page to a client computer104.

The client computer104is coupled to the server computer102through a network106. The client computer104executes web browser software that allows a user to access the web application, for example by requesting a web page from the server computer102and displaying the received web page to a user. The web browser software may also execute portions of the received web page. Examples of web browser software include Microsoft Internet Explorer, Apple Safari, Mozilla Firefox, and Google Chrome. The network106provides a communication pathway between the client computer104and the server computer102.

The network106may include multiple wired or wireless connections, and zero or more additional computers may be present in the communication pathway between the client computer104and the server computer102. The network106may include an electrical connection, an optical connection, a radio frequency connection, any other suitable communication connection, or a combination of multiple connections. The network106may include equipment such as switches, routers, hubs, multiplexers, demultiplexers, modulators, demodulators, and other suitable equipment. Alternately, the network106may be a virtual connection in the case of a loopback interface or virtualization software that allows the web browser software and the web server software to execute on the same computer hardware. The network106may also include additional clients and servers that are not illustrated. Examples of a network106include an internet such as the public Internet, an intranet such as a private corporate network.

In other embodiments, documents other than web pages may be requested and transmitted by the client104and server102. For example, the documents may be XML documents, JSON documents, or a combination of different document types or formats.

The client104, server102, and database108may include one or more devices (not illustrated) for storing data to and retrieving data from a computer readable medium. The devices may be incorporated into one or more of the client104, server102, and database108, or they may be attached either directly or indirectly, or they may be accessible over a network or data bus, or any combination of these. Example devices include registers, volatile memory such as random access memory, and nonvolatile memory such as a hard drive or optical drive. It is understood that storing data, which is generally binary in nature, to any of these computer readable media requires a transforming the state of a physical article. For example, storing a data bit to a register or to RAM generally involves charging or discharging a capacitor or setting the state of a flip-flop. Storing a data bit to magnetic media generally involves changing the magnetization of one or more grains within the magnetic medium. Storing a data bit to an optical disc generally involves scorching an organic dye or changing the phase of a metal alloy. Thus, storing a data bit to a computer readable medium involves updating a physical article so that it contains a representation of the stored data bit. Storing larger or more complex data is achieved by storing all of its constituent bits, whether sequentially or simultaneously or both. References to computer memory or other storage devices throughout are intended to cover any suitable computer readable medium.

Turning now toFIG. 2, illustrated is an exemplary system200for delivering a service or a document to a user. In many instances the user is an individual, but the user may also be a computer, service, process, controller, or any other type of user. The user uses a client program, illustrated as web browser202, to initiate a request for information, such as a web page, XML response, or other document. An example of a request is an HTTP GET or POST message. The request is sent to a server program, illustrated as a web server204, although other types of servers are also possible. In the specific example ofFIG. 2, the web server204is a computer running Microsoft Internet Information Server (IIS), but other server or web server software are also contemplated. The web server passes the request to an application framework206, illustrated as the object-oriented .NET Framework available from Microsoft although other application frameworks, including both object-oriented and non-object-oriented application frameworks, are also contemplated. Within the application framework206, the request is identified as a request for a specific web page208, illustrated in this example as a web page labeled “Products.aspx.” It is understood that the request may also identify an object, procedure, or command for producing a web page or other suitable response to the request. As illustrated, the web page208is a server-side executable program that includes any number of sections of HTML210and server scripting212. The sections of HTML210may optionally include additional non-HTML content, such as JavaScript code, comments, or other content. The server scripting212may identify or define objects, such as .NET controls, for producing a relevant portion of the response. The web page208as illustrated has an associated code-behind page214, which may be shared with other web pages. It is understood that some web pages, or parts of web pages, may not have an associated code-behind page. The code-behind page214includes additional server-side executable code used in generated a response to the request from web browser202. The code-behind page214may be written in any suitable language, including for example Visual Basic or C#, and may be compiled before or during execution.

In response to the received request from the server204, the application framework206renders the web page208to produce a response, illustrated as an HTML output216. In rendering the web page208, the application framework206executes the instructions in the server scripting212, which may cause the instantiation of one or more objects corresponding to the .NET controls in server scripting212. The application framework206may also execute functions, procedures, and/or methods in the code-behind page214, which may in turn cause the instantiation of additional objects. The instantiated objects may produce some or all of the contents of the HTML output216. The HTML output216may be specifically tailored to the received request, for example, by incorporating information about the user, for example, the user's name, location, or account. After the output216is produced, the application framework206provides the output216to the web server204, which in turn sends the output216to the web browser202where it is produced for the user.

FIG. 3illustrates an optimization technique300for part of a network application that produces a static output. Although the example ofFIG. 3is illustrated using the ASP.NET platform available from Microsoft Corp., it is understood that other technology platforms could be used instead or in addition.

The network application includes an exemplary web page302named Products.aspx. The web page302includes various sections of HTML code304and a .NET control section306. The .NET control section306in this example does not have an associated code behind page. An example .NET control section with no associated code behind page is illustrated in a code segment400inFIG. 4, which illustrates an example of a menu structure designed using asp:Menu and asp:MenuItem objects.

Rendering the Products.aspx web page in the standard .NET framework causes the instantiation of all of the asp:Menu and asp:MenuItem objects defined in the code segment400ofFIG. 4. But the HTML output of these objects is always the same. Thus, when a client requests the Products.aspx page, the processing required to produce a response is reduced by substituting a static HTML308output for the corresponding .NET control section306. An example HTML output is illustrated in an HTML segment500inFIG. 5. The resulting web page310, in this illustrative example, includes only HTML and has no .NET controls. Thus, rendering the web page310does not require the instantiation of any .NET objects. Those of skill in the art will recognize that in some instances, a .NET control section306may be replaced with a combination of HTML and client-side executable code, such as JavaScript.

FIG. 6illustrates an optimization technique600for part of a network application that produces a dynamic output. Although the example ofFIG. 6is illustrated using the ASP.NET platform available from Microsoft Corp., it is understood that other technology platforms could be used instead or in addition.

The network application includes an exemplary web page602named Products.aspx. The web page602includes various sections of HTML code604and a .NET control section606. The .NET control section606in this example has an associated code behind page608named Sitename.dll. An example .NET control section and associated code behind page is illustrated in code segments700and702, respectively, inFIG. 7.

Rendering the Products.aspx web page in the standard .NET framework causes the instantiation of the object or objects defined in the .NET control section606. Rendering may also cause the execution of the corresponding code behind, such as some or all of the code segment700ofFIG. 7. The code behind code segment700accesses an object's functionality, properties, and events through various methods associated with the object. Execution of these methods at runtime requires first locating the appropriate class associated with the object, then locating the called method for that class or a superclass, and then finally executing the corresponding instructions of the method. In an application framework such as .NET, it is common for objects to be arranged in a hierarchy to exploit the advantages commonly associated with object-oriented programming, such as inheritance, encapsulation, and abstraction. Thus, even executing a relatively simple method such as a “getText” or “setText” method may require many instructions at runtime.

Accordingly, the optimization technique600includes substituting an optimized web page612for the web page602. The optimized web page612includes an optimized control section610in place of the .NET control section606used in web page602. The optimized control section610causes the instantiation of one or more optimized objects corresponding to the object or objects instantiated by the .NET control section606. The optimized objects are of an optimized control class that represents all control properties as a simple array, such as a string array or a data array. This prevents unnecessary function calls, object accesses, and object hierarchy overhead. Alternately, the optimized control section610may use only HTML, JavaScript, or a combination of both to create a corresponding control object, thus eliminating the need to instantiate any corresponding objects during execution or rendering. Corresponding changes are made to the code behind code segment, as shown inFIG. 7. Code segment702, corresponding to the optimized code behind code segment614, stores and accesses various control properties in a string array named ControlString. For example, the control's text may be stored as ControlString[1], the background color as ControlString[2], and the font style as ControlString[3].

Thus, executing the OnChangeEvent( ) of code segment702, as compared to executing the code segment700, does not require finding or executing any methods associated with storing or retrieving control properties. Instead, the properties can be set and accessed through direct memory accesses to a string array.

Accessing a control's properties through a string or other array generally requires a mapping to ensure that the array elements are used consistently throughout an application.FIG. 8illustrates an exemplary mapping800for some of the properties of a textbox control. As illustrated, the mapping is written as an XML document, but it is understood that the mapping may be in any format.

When the web page612is rendered in response to a client request, the optimized control section610may produce an HTML output similar to or the same as the .NET control section606. Alternatively, the produced output to be in an alternate format that is more memory efficient. In particular, it is noted that an HTML output for an input text field includes various delimiters such as <input> and </input> tags, thus adding at a minimum fifteen additional characters of output for every input text field in the output. Additional delimeters may also be part of an HTML output. Thus, it is preferred for the optimized control section610to produce a more compact output format that includes all of the necessary contents without unnecessary delimiter characters. An example of such a format is explained more fully below.

The output may additionally include instructions executable by a client to reformat the alternate format output to an HTML format. The client-side executable instructions may be a JavaScript routine. Optionally, the output may include a reference to such instructions, such as a JavaScript function call, while the detailed instructions themselves are accessed from another location, such as a separate JavaScript file. After the output is returned to the client, the JavaScript routine is executed by the client and results in creating an HTML output using the provided data and properties. The HTML output can then be rendered by the client. Because the alternate format output does not include all of the mark-up tags associated with a fully-tagged HTML output, the size of the optimized output produced by optimized control section610may be less than a corresponding HTML output produced by the .NET control section606.

The techniques described above can be applied to substantially any control. The inventors have discovered, however, that certain controls (including, for example, controls that produce table-formatted output) can be optimized even more effectively with the following approach.FIG. 9illustrates an object-oriented network application900that produces information in a table format. Although the example ofFIG. 9is illustrated using the ASP.NET platform available from Microsoft Corp., it is understood that other technology platforms, whether object-oriented or non-object-oriented, could be used instead or in addition.

The network application900instantiates a GridView object902, which in the .NET framework is a control object for producing a tabular output. Those of skill in the art will recognize that other controls could also be used, and that the output may or may not be tabular. The control object may be any kind of control or object, and the control object may or may not produce a visible output. For example, the control object may be a property object, such as a color object. The GridView object902either instantiates or communicates with a DataSet control904, which provides an interface to a data store906, such as a file or database. The DataSet control904, in turn, retrieves raw data908from the data store906and then provides the data to GridView object902.

The GridView object902is customizable by a programmer through various properties910, events912, actions914, and customizations916. These elements allow the programmer to expand or tailor the functionality of the GridView object902to meet the requirements of the network application. During the execution of various events912and actions914, additional objects may be instantiated. In particular, during the rendering of the GridView object902to produce an HTML output918, a variety of additional HTML objects920may be instantiated. It is well understood that other objects (not illustrated) may also be instantiated during this processing, and that the output may be in another document format, including for example an XML document, a JSON document, or other type of document.

FIG. 10illustrates an alternate framework1000for providing an object-oriented network application that displays information in a table format. LikeFIG. 9,FIG. 10is illustrated using the ASP.NET platform available from Microsoft Corp., but it is understood that other technology platforms, whether object-oriented or non-object-oriented, could be used instead or in addition.

The framework1000includes a OptimizedGridView object1010. Like the GridView object902ofFIG. 9, the OptimizedGridView object1010is a control object for producing tabular output. But as will be further illustrated below, the OptimizedGridView object1010produces a substantially similar or functionally equivalent output while consuming considerably fewer execution and memory resources. More specifically, the instantiation and rendering of an OptimizedGridView object1010causes the instantiation of fewer additional objects, or perhaps even does not directly cause the instantiation of any additional objects. In some embodiments, the OptimizedGridView object1010may provide a subset of the features available with the GridView object902. For example, the OptimizedGridView object1010may implement only the most commonly used features and capabilities of the GridView object902. In addition, the OptimizedGridView object1010may provide features not available with the GridView object902. Thus, the OptimizedGridView object1010may provide a suitable replacement object for applications using the GridView object902.

The OptimizedGridView object1010either instantiates or communicates with a DataSet control1012, which provides an interface to a data store1016, such as a file or database. The DataSet control1012, in turn, retrieves raw data1014from the data store1016and then provides the data to OptimizedGridView object1010. Thus, the OptimizedGridView object1010is able to access all of the same data stores, and through substantially similar mechanisms, as the GridView object902.

The OptimizedGridView object1010retrieves the data1014through the DataSet Control1012and formats the data for presentation as the output1018. The OptimizedGridView object1010preferably produces the output1018with a minimum of additional object instantiations. And while the OptimizedGridView object1010may produce an HTML output similar or the same as HTML output918produced by the GridView object902, it is preferred for the produced output to be in an alternate format that is more memory efficient. In particular, it is noted that an HTML table output delimits each data element with <td> and </td> tags, thus adding at a minimum nine additional characters of output for every data element within the table. Additional delimeters, such as <tr> and <th> tags (and their corresponding closing tags), may also be part of an HTML table output. Thus, it is preferred for the OptimizedGridView object1010to produce a more compact output format that includes all of the necessary table contents without unnecessary delimiter characters. An example of such a format is explained more fully below.

The output1018may additionally include instructions executable by a client to reformat the output1018to an HTML format. The client-side executable instructions may be a JavaScript routine. Optionally, the output1018may include a reference to such instructions, such as a JavaScript function call, while the detailed instructions themselves are accessed from another location, such as a separate JavaScript file. After the output1018is returned to the client, the JavaScript routine can create an HTML table output using the provided table data and table properties. The HTML table can then be rendered by the client. Because the output1018does not include all of the mark-up tags associated with an HTML table, the size of the output1018is less than a corresponding HTML output918inFIG. 2.

It can be appreciated that the framework1000enjoys a number of advantages over the application900. First, instantiation and use of the OptimizedGridView object1010requires fewer processing and memory resources when compared with the GridView902. Because fewer objects are created and destroyed, there is a substantial savings in memory usage. And because the OptimizedGridView object1010avoids the use of many objects, those objects' initialization and clean-up routines do not have to be executed, resulting in a reduction in processing time. And since the output of OptimizedGridView object1010is smaller than the output of GridView902, less communication bandwidth is needed to transmit the response back to the requester.

Thus, the framework1000can respond to requests using fewer memory, processing, and communication resources. Because of this increased efficiency, the framework1000can handle more requests than the application900using the same or equal hardware.

The example ofFIG. 10is not limited to handling only table-style controls such as a .NET GridView. The same similar approach can be taken with other .NET controls by replacing a standard .NET control with an optimized replacement that provides some or all of the same functionality but with higher efficiency. Examples of other .NET controls that can be replaced include validation controls, menu controls, list controls, and other controls. Furthermore, it is understood that the example ofFIG. 10is also not limited to .NET controls, but could be adapted to any other application framework, whether object-oriented or non-object-oriented.

As noted above in the discussion ofFIGS. 6 and 10, the output of an optimized control may be in an alternate format. This alternate format may then be processed by client-side code, such as a JavaScript routine, to produce HTML output for rendering in a web browser.FIG. 11illustrates exemplary code portions to further explain an alternate output format. In the illustrated example, an original Example.aspx page1102includes an ASP.NET TextBox control identified as “t1.” An associated code-behind1104defines a function that, when executed, sets the background color of the t1 TextBox to blue. It is understood that this is merely an example, and that more complex or sophisticated applications of the disclosed technology are also contemplated.

The Example.aspx page1102is replaced with an Optimized Example.aspx page1106, and the associated code-behind1104is replaced with an optimized code-behind1108. The Optimized Example.aspx page1106defines an HTML text input field having the same identifier as the ASP.NET TextBox control, “t1.” The Optimized Example.aspx page1106also includes a call to a JavaScript function, buildTextbox( ), that will initiate the setting of certain settings for the t1 text input control when it is later produced by the receiving client. And an ASP.NET server-side script section is added to the Optimized Example.aspx page1106with a call to a RenderControlStrings( ) procedure.

Corresponding changes are made to the optimized code-behind1108. The instructions contained in optimized code-behind1108is illustrated as being written using C# for the benefit of explanation, but it is understood that the optimized code-behind1108may be created as a compiled library using the Common Intermediate Language (CIL) as more fully explained below. A global string array variable, control_text1, and a global integer variable, control_text1_n, are defined. These two variables are used to store values assigned to attributes of the t1 text input during the server-side rendering of the Optimized Example.aspx page1106. For example, the statement in the code-behind1104that sets the background color to blue is changed into a sequence of statements that will cause the equivalent output. Specifically, the 0thindex position of the control_text1 string array is used to store a sequence of property identifiers corresponding to control attributes. As illustrated inFIG. 8, the attribute for background color may be assigned the property identifier 2. Next, the other index positions of the control_text1 string array are used to store the assigned values. Thus, in the first position, the RGB value corresponding to the color blue, #0000ff, is stored. Then, the control_text1_n counter is updated so that a next attribute, if any, can be stored.

The optimized code-behind1108also provides a definition of the RenderControlStrings( ) procedure called by the Optimized Example.aspx page1106. Specifically, the RenderControlStrings( ) procedure injects JavaScript variable definitions for the control_text1 variable used by the buildTextbox( ) function. An example of the output is shown as an Optimized Example.aspx page after server-side execution1110. There, the server-side script has been replaced by a JavaScript code portion that defines the control_text1 variable as a string array with two strings.

The example ofFIG. 11is understood to be merely one example of how one attribute on one type of control can be optimized. The technique can be applied to substantially any attribute and any control, and furthermore various functions and procedures used in the optimization can be reused across multiple controls.

As noted above with reference toFIGS. 6,7, and11, substituting an optimized control for a .NET control may require modifying instructions in an associated code behind. These changes could be accomplished by modifying the original code behind source code, but doing so requires access to the original code behind source code. In addition, the changes made to the code behind source code would generally depend on the programming language used by the code behind. Those of skill in the art will recognize that the changes needed for a Visual Basic code behind are different from those needed for a C# code behind.

An alternate approach is to make the necessary changes directly to a compiled dynamic link library (DLL) produced by the .NET compiler. The DLL includes instructions in a compiled format known as Common Intermediate Language (CIL) or Microsoft Intermediate Language (MSIL). The DLL instructions can be decompiled and modified using, for example, tools such as .NET Reflections and Mono Cecil. Suitable alternate tools can be employed when working with frameworks other than .NET.

FIG. 12illustrates an example approach to modifying a compiled CIL program. Original C# source code1202includes a statement1204setting the background color of a Label control to red. After being compiled by the .NET compiler, the statement1204results in the instructions1206. The instructions1206load the specific object instance of the Label, determine a value associated with the color red, and then assign that value to the object instance's BackColor property.

In accordance with the techniques of the present disclosure, the instructions1206can be rewritten as the optimized instructions1208. The optimized instructions1208may, for example, correspond to one of the replaced lines of code in the optimized code behind702ofFIG. 7.

FIG. 19illustrates an example approach to modifying a compiled CIL program. The example ofFIG. 19builds on the previous disclosure ofFIG. 12. The compiled instructions1206are matched against a pattern1902. The pattern1902, which may be stored in the database format described inFIG. 18, represents an instruction set that includes a first block1904and a second block1906, although more or fewer blocks are also contemplated. The number of blocks may depend on the specific control property, method, or event being invoked or referenced by the instructions1206.

The first block1902includes a wild card portion1908that corresponds to a location in the instructions1206where a variable name occurs. Since variable names are assigned by the programmer, they cannot be predicted in advance and the optimization process must take into account that a variable name will change from one application to another, or that multiple variables with different names may be used in a single application. The first block1902also includes an object type portion1910. The second block1906includes a base class type portion1912, which may be the same as or different than the object type portion1910. The second block1906also includes a function signature portion1914that identifies a method or function of the base class.

Between the first block1904and the second block1906are a number of lines, n, that are variable depending on the complexity of the supporting code. The n lines may also include other instruction sets. Thus, instructions sets may be nested inside other instruction sets. Because instruction sets may be nested, it is not always apparent where an instruction set begins or ends.

FIG. 20illustrates a process for identifying a beginning and an end of an instruction set. The process implements a stack trace algorithm that evaluates the stack count value by determining how each instruction affects the stack count. IL instructions can either add items to the stack, pop items from the stack, or evaluate items on the stack without affecting the stack count. In step2002, the first block of an instruction set is identified, for example, by a “ldarg.0” instruction followed by an object type and ID. In the example ofFIG. 19, this corresponds to an object type of System.Web.UI.WebControls.Label with the name Control1. Next in step2004, an initial stack count is determined. In the example ofFIG. 19, the stack count begins with 2, but the beginning stack count can be any value depending on its location in the IL code. Then in step2006, the stack increment of the next instruction is determined. In the example ofFIG. 19, the next instruction is the “ldfld” instruction with a stack increment of +1 because the instruction adds one item to the stack. Although described as a stack increment, it is understood that the stack increment value may be positive, negative, or zero. In step2008, the stack increment is added to the stack count, resulting in a stack count of 3 in the example. Then in step2010, the current stack count (3) is compared to the initial stack count (2). If the current stack count equals the initial stack count, processing continues to step2012, where the last instruction is identified as the end of the instruction set. If in step2010the current stack count does not equal the initial stack count, then processing loops back to step2006.

As shown in the example ofFIG. 19, the “callvirt” instruction has a stack increment of −2 because it pops two items off the stack. This results in the current stack count equaling the initial stack count and indicates that the “callvirt” instruction is the end of the instruction set that begins with the “ldarg.0” and “ldfld” statements.

After an instruction set is identified using the process ofFIG. 20, the object type, base class type, and function signature can be identified as shown inFIG. 19. These values and the instruction set are used to query the pattern database for a matching result. The .NET Reflection tool may be used to query the pattern database, which may be implement in pure IL with the patterns created as IL blocks. An example IL block pattern is shown inFIG. 18as pattern1810. The pattern1810corresponds to the base class type and function signature of the IL instructions in the example ofFIG. 19. Thus, the optimization process retrieves the pattern1810from the pattern database and extracts the instructions therein to replace the IL instructions ofFIG. 19. In the specific example of pattern1810, there is an object type1812(“System_Web_UIWebControls_Label”), function signature1814(“setText( )”), and optimization command and associated block descriptions1816. As previously noted, each pattern may have more or fewer blocks. The optimization command or commands may be to ignore, verify, replace, or type change the original instructions. In most instances, the optimization command will be to replace the original IL instructions with optimized counterparts. The optimized counterparts may be optimized relative to the original IL instructions in a variety of ways, including, for example, that the optimized counterparts execute faster, require less memory, access fewer resources, or produce output that requires less time to transmit over a network.

FIG. 21illustrates a progression of optimizing an instruction. The initial compiled IL code2102is matched to a pattern2104. The pattern2104is evaluated to provide replacement optimized instructions2106. For example, the replacement instructions2106are substantially equivalent to the C# statement, “m_EkkoTxt[1]=‘Please enter a value’;”.

From the example explained in detail above, it can be appreciated that instructions for setting or getting substantially any property for substantially any .NET control can be readily replaced with optimized instructions that access the relevant properties using the control string techniques of the present disclosure. Given that many .NET controls have few or no methods or events other than those for getting and setting properties, these .NET controls can be replaced with corresponding optimized controls that provide equivalent or the same functionality. To do so, it is appreciated that one approach is to build a database of generic templates of instructions and optimized templates of instructions, as generally discussed above with respect toFIG. 12. The library preferably should include templates corresponding to each supported property or attribute of each supported control object class.

FIG. 13illustrates a system1300for building a database of instruction templates. The system1300includes a control1302that is input to a pattern creation tool1304. The pattern creation tool1304introspects the control1302to determine its properties, functions, and events. The pattern creation tool and compiler1304then generates and compiles example source code to activate some or all of these properties, functions, and events. The generated source code may be, for example, C# source code or Visual Basic source code. The source code is then compiled to produce a generic form of IL that is analyzed by an IL pattern analysis tool1306to identify one or more IL instructions for that correspond to each property, function, or event. The one or more IL instructions are used to generate an IL statement pattern1308for each corresponding property, function, or event. The IL statement pattern may include a portion that matches against a wildcard, for example, for matching against a variable name. For each identified pattern, a replacement pattern1310is also provided. These search patterns and replacement patterns are then stored in a database1312. The database may be an IL dynamic link library (DLL), thus allowing .NET Reflection to be used to read and to search the patterns. Since the properties, functions, and events associated with a control may change with each version of the .NET framework, separate databases1312may be created for each supported version of the .NET framework.

The system1300may operate automatically, allowing a large number of controls to be quickly analyzed. The system1300may also operate semi-automatically, such that a user guides and oversees the system's operation but some aspects remain automatic.

To handle some events, such as an OnChange event triggered by a user changing the value of a control object, the initial values of optimized control objects may be stored in a hidden field inserted into a rendered web page. When a client sends a subsequent request, such as HTTP POST message, the value of the hidden field will be included in the POST message. Thus, during processing of the POST message, the initial values (retrieved from the hidden field) may be compared to the then-current values (also provided in the POST message) to determine if a field value has changed. If so, the associated OnChange event is triggered. Other events can be handled in a similar fashion.

FIG. 18illustrates a database format1800for storing details about supported controls. The database format1800may be used, for example, to organize data stored in databases1312. The database format1800includes a type value1802to indicate a control, which may be a specific control or a class of controls. For a type value1802, the database format1800includes properties1804, methods1806, and events1808. Although described using the plural sense, it is not required that a type value1802have multiple properties1804, methods1806, and events1808. Thus, it is understood that a type value1802may alternately have zero or more properties1804, methods1806, and events1808. For each property1804, the database format1800stores a pattern that matches an IL statement pattern generated by code accessing the corresponding property of the type1802. The methods1806and events1808are similarly organized. The database format is organized to allow multiple records to be efficiently stored and searched, thus supporting the code optimization processes described herein.

The optimization technology of the present disclosure can be readily integrated with the optimization technology described in the applicants' co-pending U.S. application Ser. No. 12/477,416, “Web Page Optimization,” filed Jun. 3, 2009, the contents of which are hereby incorporated by reference for all purposes. Thus, after replacing ASP.NET controls with HTML equivalent controls, as discussed generally above with respect toFIG. 12, the replacement HTML equivalent controls are defined by server-side static code that can optionally be compressed.

It is noted that ASP.NET applications can use a concept known as a Master Page that defines attributes and content that are inherited by one or more other pages.FIG. 14shows an example of how pages can be optimized when they inherit attributes and content from a master page. An ASP.NET master page1402includes a dynamic portion1404and a static portion1406. Within the dynamic portion1404there is a content placeholder that can contain, for example, either content control A or a content control B. Illustrated is the content control A1408, which is also divided into a dynamic portion1410and a static portion1412. The dynamic portion1410begins with an identifier1414, and the static portion1412ends with a corresponding identifier1416. As illustrated, the identifiers1414and1416each have a length of 5 bytes, but it is understood that the identifiers may be longer or shorter, and they may be of unequal length. Part or all of an identifier may identify a file or other data store, either directly or indirectly, that includes additional information for processing the content control. A separate data store, not shown, may store additional information, such as the location of escape sequences or characters that must be replaced before the content is provided to a requester. As illustrated, the identifiers1414and1416each begin with the control byte value 0x0F, which is treated as a reserved byte value that indicates the beginning of a header or footer identifier. The next byte has a value of either 0 or 1. The value 0 indicates that the identifier is a header identifier marking the beginning of a portion, and the value 1 indicates that the identifier is a footer identifier marking the end of a portion. The next three bytes or characters represent an alphanumeric identifier, which in the illustrated example is 31A. It is understood that identifiers may be structured differently and may have or use any suitable format. The dynamic portion1410also includes an empty header1418, which may be subsequently populated as a GZIP, zlib, or other compression block header.

FIG. 15illustrates a process1500for optimizing a web application. Although the process1500is illustrated and described herein with respect to an ASP.NET web application, it is understood that the web application may use any suitable framework. The process1500begins in step1502with identifying a target web application. The target web application may be an entire web site, or just a portion thereof, for example, a single web page. Continuing in step1504, an original ASPx page is identified. Then in step1506, the code-behind associated with the ASPx page, if any, is identified. In step1508, the compiled code-behind code is decompiled and introspected along with the ASPx page. Because all .NET code compiles to a Common Intermediate Language (CIL) format, processing the compiled code-behind code allows the process1500to operate independently of whatever language the code-behind was originally written in. For example, it does not matter for the process1500whether the code-behind was written using Visual Basic or C#. The decompilation of step1508may be accomplished using, for example, the Reflections toolset that is provided as part of ASP.NET or the Cecil library available as part of the open source Mono project. As an alternative to decompilation, the code-behind may be analyzed in its original source code format. As yet another alternative, a custom execution environment can be created for executing the code-behind in a controlled environment that records the actions caused by executing the code-behind.

Then in step1510, an analysis is made of the objects, methods, properties, and events are used in the code-behind. This analysis may be directed to determining if any ASP.NET server controls are modified or used in the code-behind. Examples of modification or use include if the contents of an object or its properties are changed, if a control triggers a postback event, or if an object is passed as a parameter in a method call. As a specific example, where the ASPx page uses a GridView control, the introspection may include determining how the methods, properties, and events of that GridView control are used.

In step1512, a decision is made based on the analysis from step1510as to whether the ASPx page and associated code-behind use only the subset of features supported by an optimized replacement control. If only supported features are used, then in step1514the ASPx page is rewritten to use the optimized replacement control instead of the original control. If unsupported features are used, then processing continues to step1516.

In step1516, a determination is made whether there are additional controls to be analyzed. If so, then processing returns to step1510to handle the next control. If there are no more controls, then processing continues to step1518.

In step1518, a determination is made whether there are additional ASPx pages to be processed. If so, then the next page is identified and processing continues to step1510to process it. If there are no more pages, then processing continues to step1520. In step1520, the changes made in the process1500to the web application are saved. As an alternative, the changes may be saved as they are made throughout the process1500. The changes may be saved to a new location so that the original files associated with the web application are not disturbed. Finally in step1522, the updated web application is deployed. The application may be deployed to a test or production environment.

Turning now toFIG. 16, illustrated is a process1600for analyzing usage of a control object that is part of an application. The process1600may be used, for example, as part of the process1500. The process1600begins in step1602with identifying the control's properties that are assigned values by the application. Then in step1604, the control's methods called by the application are identified. In step1606, the control's events that cause the execution of application logic are identified. In summary, steps1602-1606identify substantially all of the ways that the application uses the control under analysis.

The process1600then continues with determining a functionally equivalent technique for creating each of the control's properties, methods, and events used by the application. In step1608, it is determined whether a property, method, or event results in a static result. For example, the control may have a color property set to a fixed color and that produces an in-line CSS command or HTML tag property. The determination of step1608may be made for each property, method, and event separately, or they may be considered in groups or as a whole. For example, an entire asp:Menu structure and its constituent sub-objects may be evaluated together as a group. If in step1608it is determine that the result is static, then in step1610the static result can be used in place of the property, method, or event. The static result may be a portion of text, such as HTML, Javascript or other code. The static result may also be a visual styling command, such as a portion of CSS code.

If in step1608it is determined that the property, method, or event does not produce a static result, then in step1612it is determined whether a replacement optimized control provides a functionally equivalent property, method, or event. If so, then the functionally equivalent property, method, or event is used in step1614. The replacement optimized control may include executable code that will execute on the server, on the client, or on an intermediary network node. For example, the replacement optimized control may be another object or group of objects or a Javascript routine or portion thereof.

Then in step1616, it is determined whether there are any further properties, methods, or events to be analyzed. If so, then processing returns to step1608to handle the next property, method, or event. If not, then processing ends in step1620by using the replacement controls and/or static results.

If in step1612it is determined that a replacement optimized control does not provide a functionally equivalent property, method, or event, then the original control will not be optimized and the process ends in step1618.

Turning now toFIG. 17, illustrated is another approach for optimizing an application. The process begins in step1702with monitoring the application for a request from a client. Then in step1704, the process continues with capturing the information dynamically accessed by the application in response to the request. The information may be, for example, one or more records from a database associated with the application. Next in step1706, the application's completed response to the request is captured. Steps1702to1706may optionally be repeated multiple times to produce multiple captured examples of access information and their associated completed responses.

In step1708, the response and accessed information are analyzed to identify which parts of the response were formed using the dynamically accessed information, and conversely, which parts of the response were formed from substantially static data. Thus, this analysis step allows the substantially static portions of the response to be identified and separated from the complete response. Next in step1710, a response template is produced. The response template incorporates the substantially static data along with placeholder identifiers that indicate where each item of dynamically access information was found in step1708. The placeholder identifiers, either alone or in combination with a data map, indicate the relevant data source for each item of dynamically access information. For example, the placeholder identifier or an associated data map may indicate that a certain field is to contain a user's name as stored in a field on a table in the database.

Next in step1712, a new request is received and responded to using the response template generated in step1710. Because only the dynamically access information needs to be accessed and processed, and because the remainder of the response is known to be substantially static, the computation burden on a server responding to the new request is dramatically lower.

FIG. 22illustrates an application optimization system and process. The system includes an optimization engine2202and associated pattern database2204. Although illustrated as a single database, it is understood that the pattern database2204may include multiple databases. A target web application includes a web page2206and code-behind2208, although the application may of course include many web pages and code-behinds. The optimization engine2202parses the web page2206to locate and subsequently identify any controls or objects used there. The optimization engine2202then loads instruction patterns from the pattern database2204. Next the optimization engine2202searches for matching patterns in the code-behind2208. Using information from the pattern database2204, the optimization engine then replaces instructions in the code-behind2208to produce an optimized code-behind2210. The optimization engine also replaces controls in the web page2206to produce an optimized web page2212.

FIG. 23illustrates an example of optimizing a control. A web page portion2302includes a statement declaring a button with ID btnContinue, a text label of “Continue . . . ”, a width of 200 and a color blue. An associated code behind segment2304modifies the button's height to 30 and sets the font to Arial. An optimized web page portion2306includes a button declaration as a standard HTML control. The optimized web page portion2306also defines a hidden HTML element that contains values representing button properties that are set dynamically. Finally, the optimized web page portion2306includes a Javascript portion to be executed on the client side to call a buildButton( ) function that accepts as arguments two control IDs. The first control ID specifies the optimized control and the second control ID specifies the hidden HTML element that contains dynamic properties for the optimized control. The Javascript function may be specific to the particular control being optimized. Alternatively, the function may be common to multiple controls and may accept an additional parameter indicating the type of control to be built.

The hidden HTML element encodes dynamic properties using comma separated values. Other encoding approaches may also be used instead of or in addition to comma separation. The first value specifies the total number of dynamic properties, in the example case, 2. Since there are 2 dynamic properties, the next 2 values specify index values that identify the specific properties. In the example case, the value 4 indicates that the dynamic property is the height, and the value 30 indicates that the dynamic property is the font. Next, the values of the properties are provided. In the example case, the height is set to the value 30 and the font is set to the value arial.

FIG. 24illustrates another example of optimizing a control. The example begins with the same web page portion2302and associated code behind segment2304as in the example ofFIG. 23. An optimized web page portion2406includes two hidden HTML elements, one for statically defined properties and a second for properties that are set dynamically. The optimized web page portion2406also includes a Javascript portion to be executed on the client side to call a buildButton( ) function that accepts as arguments three control IDs. The first control ID specifies the control ID to be created, the second control ID specifies the hidden HTML element that contains static properties for the optimized control, and the third control ID specifies the hidden HTML element that contains dynamic properties for the optimized control. The hidden HTML elements encode the control properties using the approach described above inFIG. 23.

It is particularly noted that a substantial portion of the optimized web page portions2306and2406is static. Only the dynamic values assigned during execution of the code-behind are non-static. Thus, the remaining static portions can be further compressed and optimized using the optimization technology described in the applicants' co-pending U.S. application Ser. No. 12/477,416.

FIG. 25illustrates a process for rendering a web page. The process2500may be used, for example, to render a web page on a client computer system when the web page includes a web page portion that has been optimized using the techniques discussed herein. Any individual step, or the even the entire process, may be performed as part of a Javascript or other programming language routine. The process2500begins at step2502with receiving a web page from a server, which may be local or remote. Receiving the web page from the server may include a sub-step of decompressing some or all of the web page content. For example, the web page may be received from the web server in a GZIP format that requires decompression. Next in step2504, the web page is parsed to identify a control ID. The control ID may identify, for example, an HTML control that is declared and instantiated elsewhere in the web page. The control ID may also identify an HTML or other kind of control that is to be instantiated. If the control does not exist and is to be instantiated, the step2504may optionally include the substep of instantiating a control with the identified control ID. Alternatively, the control may be instantiated later in the process when further details about the control's property or properties have been extracted from the web page. Then in step2506, a data array in the web page is parsed to identify an associated property to be set for the control. The data array may be, for example, a string array of comma separated values, although other approaches and data structures for identifying a property are also contemplated. The property may be identified by an index value, such as the index values discussed previously with respect toFIG. 8. Next in step2508, the data array in the web page is parsed to identify a property value for the property. Although it is contemplated that the data array of step2508is the same data array of step2506, this is not necessarily so. The property value may have been dynamically determined by the server during the preparation of the web page. For example, the property value may depend in part on information provided to the server when requesting the web page or on information associated with a user. As described in applicants' co-pending U.S. application Ser. No. 12/477,416, the dynamically determined property value may be received from the server in an uncompressed format, even though other parts of the web page are received in a compressed format. Finally in step2510, the control is modified to set the property to the property value. The process2500may also continue by iterating over additional properties and property values in the data array or arrays. For example, the process2500may include processing two separate data arrays like those illustrated inFIG. 24.

This disclosure is described in the context of requesting and serving web pages over a network as part of a Microsoft ASP.NET web application. But those of skill in the art will recognize that the present disclosure may be used in other contexts. For example, the technology may be used within a single computer without the requirement of a network. As another example, the disclosed techniques may be applied to documents other than web pages, such as interpreted or compiled scripts or programs, XML documents, database records, or any other kind of document. As a further example, the disclosed techniques may be applied to applications using other frameworks, including but not limited to Java, IBM WebSphere, and Adobe ColdFusion.

The present disclosure has been described relative to a preferred embodiment. Improvements or modifications that become apparent to persons of ordinary skill in the art only after reading this disclosure are deemed within the spirit and scope of the application. It is understood that several modifications, changes and substitutions are intended in the foregoing disclosure and in some instances some features of the invention will be employed without a corresponding use of other features. Accordingly, it is appropriate that the appended claims be construed broadly and in a manner consistent with the scope of the invention.