Using the cache technology in ASP can largely improve your website performance. In fact, these implementation methods are very simple. It will explain how the cache on the server is how to work ADO connection technology.
Before introducing these technologies, let's explain what is the cache technology of ASP.
The so -called cache is actually opening a space to save data in memory. Using the cache, you do n’t need to visit the data you stored on the hard disk. Flexible use of the cache. The torture when reading data. Once you perform a query action and put the query results into the cache, you can quickly visit the data quickly. And if you do not put the data into the cache, when you execute this query again, the server consumes the process from the database and sorted it.
When the data is stored in the cache, the time it takes when querying again is mainly at the time of displaying the data. In other words, we should not put the data that often needs to change into the cache of the server. We should change less, but we need to put the data that we often access into the cache.
Now we first discuss the technique of using ASP on the server. After that, we will discuss how ASP uses on the client
Cache technology.
When you have a lot of data (static, that is, less changes) need to be displayed to the client, you can consider using the cache technology on the server. This technology is particularly suitable for those websites with strong display style consistency (huh, for non -mainstream websites, it is not easy to use.)
In fact, the implementation method is particularly simple. Just look at the following simple example.
This is an example for displaying books classification
Displaybooks.asp file:
< %@ Language = javascript %>
<html>
<body>
<FORM METHOD = Post>
Book classification; < % = getBookslistbox () %>
<p>
<input type = submit>
< %
Function GetbooksListbox () ()
{{
Bookslistbox = Application (Bookslistbox)
if (bookslistbox! = Null) Return Bookslistbox;
Crlf = String.fromCharcode (13, 10)
Bookslistbox = <select name = books> + crlf;
SQL = Select * from Books Order by name;
cnnbooks = server.createObject (adodb.connection);
cnnbooks.open (books, admin,);
rstbooks = cnnbooks.execute (SQL);
FLDBOOKNAME = RSTBOOKS (BookName);
While (! rstbooks.eof) {
BOOKSLISTBOX = BOOKSLISTBOX + <option> +
FLDBOOKNAME + + CRLF;
rstbooks.movenext ();
}
Bookslistbox = Bookslistbox +
Application (bookslistbox) = bookslistbox
Return BookslistBox;
}
%>
It's very simple, in fact, it uses a very simple Application technology, and the difference is in one sentence:
Application (bookslistbox) = bookslistbox
You can verify that you find that the number of requests on the server will be reduced a lot. This situation is particularly suitable for websites that are not very frequent as those updates, such as you are updated only once (or a long time).
Let ’s discuss a client cache technology. This technology is also called disconnecting the connected ADO connection technology (the translation level is too much, and it sounds so awkward). This technology is mainly used to save user personal information, such as user passwords, code codes, etc. It mainly uses some attributes of ADO. At the same time, some netizens have mentioned whether the questions that can use ADO objects in Applocation. The explanation is not clear, let the code speak below:
File global.asa:
<!-Metadata type = Typelib file = C:/Program Files/Common Files/System/Ado/Msado15.dll-->
<script Language = VBScript Runat = Server>
Sub application_onstart
Sql = select username, password from userInfo
cnnusers = dsn = user
Set rsusers = server.createObject (adodb.recordset)
'Note that the following two sentences are used to achieve the ADO technology that is available for disconnecting connections
RSCSOMOMOMERSORSORLOCATION = AduseClient
rscosomers.open sql, cnnadvworks, adopenstatic, adlockReadonly
'Breaking the connection of recordset and the database
rscosomers.ActiveConnection = Nothing
Set application (RSCUSTOMERS) = RSCUSTOMERS
End sub
File users.asp
< %
'Clone method makes each user have a recordset collection
Set YourSers = Application (RSUSERS) .clone
Set username = YouRUSERS (username)
Set password = YouRUSERS (PASSWORD)
Do unil your owners.eof
%>
User name: < % = username %> User password: < % = password %>
< %
yourusers.movenext
Loop
%>