Minimizing Client Connections

To be able to reduce the number of connections that the client makes to our server when browsing, we can cache the data on the client rather than sending it each time they request a different page. To see how, consider the ways that we've used to retrieve data in the previous chapters of this book.

Client-side ActiveX Controls

The early chapters about components showed a simple component

WCCFinance
that calculated the number of payments required for a loan. We used this as an Active Server Component running in ASP on the server, which required a connection and a return HTML page each time the user wanted to do a calculation. We also used it (unchanged) as a client-side ActiveX control, which ran on the client's system. This way they had just one connection to our server to load the page (albeit extended the first time by the duration required to download the control), and they could do as many calculations as they liked without reconnecting to the server.

The downside here is that the browser must support ActiveX controls, and the user must be prepared to accept them. This is a particular problem with unsigned controls like our sample

WCCFinance
control. However the reduction in connections and resulting increase in responsiveness is a real bonus.

Server-side Business Objects

Of course, some business objects, such as the

WCCCars
component that returns a recordset of details for all the car models, is designed to run only on the server. In this case we were forced to use ASP to create an HTML page, or send the recordset directly to a VB client-side application.

How the business object retrieves that data from the data store isn’t that important when it runs server-side, as long as it does it in the most efficient way. We used ADO and an OLEDB driver to connect to a stored procedure in SQL Server, but the techniques you choose are dependent on your data store and available drivers.

Remote Data Services

One of the topics we discussed way back in Chapter 1 was the split between client-side and server-side processing in DNA-based applications. We've used the 'half-way house' technique of Remote Data Services in several earlier examples, including our Wrox Car Co showroom application.

It provides a perfect opportunity to spread some of the processing onto the client, by caching data recordsets there rather than fetching selected parts of the recordset through separate and repeated connections to the server. However RDS does carry some concerns over security, is not as flexible as ADO, and is not always as fast as you might like over a less-than-ideal network connection.

In our Wrox Car Co application we use a form of RDS, together with a totally different way of caching data, to reduce the number of connections required. You'll see more when we come to look at the application in detail later in this chapter.

© 1998 by Wrox Press. All rights reserved.