Process long running scripts and content-Large home pages

Source: Internet
Author: User
Tags execution time limit

Process long running scripts and content-Large home pages

The maximum limit for script uptime is 90 seconds, which is a useful safeguard against infinite cycles. However, on some special occasions, you may be faced with a script running for more than 90 seconds, for example, when your script generates a very large home page, you certainly don't want the home page to display half the time limit. Then you can use the ScriptTimeout attribute of the server object to set the limit time you want. For example, the following example:

<% server.scripttimeout=150%>

<HTML>

<Head><title> Falling Star </title>

<body>

<%

Randomize

Starx=60

For K=1 to 10

Nextsecond=dateadd ("s", 10,time)

Do While Time<nextsecond

Loop

Starx=starx+3*rnd ()-1

For I=1 to Starx

Response.Write ("")

Next

Response.Write ("*<p>")

Next

%>

</body>

This script will display the star very slowly, displaying an asterisk in the corresponding position every 10 seconds. (See Figure 14.2).

This script may end correctly due to a limit of 150 seconds at the top of the page.

You can naturally also use the Server.ScriptTimeout attribute to reduce the limit time to less than 90 seconds, and you can also access the app in the Application Configuation dialog box in Internet Service Manager The Options page modifies the ScriptTimeout property, and if you change it to-1, then your script will never expire.

Allowing a script to execute for a long time creates a very important pipeline on your site's resources, and in fact, a script might execute to the point where even the user who issued the execution request has left, in which case the continuation of the script would be of no benefit to anyone. Fortunately, the properties of the response object can be helpful, and the IsClientConnected property can check whether the browser and the server are still connected. You can use this property to stop the execution of a script that the user has left. For example, the following example will always show up to connection termination.

<HTML>

<body>

<%

While 1=1

Response.Write ("hello! MAGICW3 Com. ")

If not response.isclientconnected THEN Response.End

Wend

%>

</body>

</HTML>

Note that the IsClientConnected property only works if the browser is still connected until the last Response.Write call. If you run a long-running script without outputting anything, then this property will not work.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.