|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ASP Compiling?
(global.asp is run each time any page is called). The subroutine determines the user's country by comparing their IP address against a 6Meg Access database that converts IP to country. It then sets a Session variable with the user's country. After that, each time the subroutine is called it checks to see if that Session variable is set. If it is, it exits the subroutine - without calling the Access database. Regardless, I've noticed that my website is slightly slower than before. Even though the Access database is only called once per session, does ASP compile global.asp each time it is run, and is it slowing down because it is compiling/establishing/whatever a connection to the Access database that it is not using anyway? (Hey, I know MS SQL is faster than Access! I'm trying to understand more about ASP, that's all) Thanks! Vic Victor wrote:
> I've got a website that is very fast. I just added a subroutine in Not really. Global.asp contains code for certain events: > the file global.asp (global.asp is run each time any page is called). application_onstart, application_onend, session_onstart and session_onend. Where did you put your initialization code? > The subroutine determines the user's country by comparing their IP So you used Session_onstart?> address against a 6Meg Access database that converts IP to country. > It then sets a Session variable with the user's country. > Where is this subroutine located? in a ssi file?> After that, each time the subroutine > is called it checks to see if Probably not, unless you've made the mistake of storing an ADO object in > that Session variable is set. If it is, it exits the subroutine - > without calling the Access database. > > Regardless, I've noticed that my website is slightly slower than > before. > > Even though the Access database is only called once per session, does > ASP compile global.asp each time it is run, and is it slowing down > because it is compiling/establishing/whatever a connection to the > Access database that it is not using anyway? Session or Application -- Microsoft MVP - ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM" Bob Barrows [MVP] wrote:
> Victor wrote: Global.asp or Global.asa?> > I've got a website that is very fast. I just added a subroutine in > > the file global.asp (global.asp is run each time any page is called). > > Not really. Global.asp contains code for certain events: > application_onstart, application_onend, session_onstart and session_onend. -- Mike Brind Mike Brind wrote:
> Bob Barrows [MVP] wrote: Oops. I kept mentally changing that to asa.>> Victor wrote: >>> I've got a website that is very fast. I just added a subroutine in >>> the file global.asp (global.asp is run each time any page is >>> called). >> >> Not really. Global.asp contains code for certain events: >> application_onstart, application_onend, session_onstart and >> session_onend. > > Global.asp or Global.asa? > Victor, are you talking about an include file called Global.asp? Show us the code so we can intelligently answer your question. -- Microsoft MVP -- ASP/ASP.NET Please reply to the newsgroup. The email account listed in my From header is my spam trap, so I don't check it very often. You will get a quicker response by posting to the newsgroup.
Show quote
"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message "global.asp".news:eju%23yaSzGHA.1536@TK2MSFTNGP02.phx.gbl... > Mike Brind wrote: > > Bob Barrows [MVP] wrote: > >> Victor wrote: > >>> I've got a website that is very fast. I just added a subroutine in > >>> the file global.asp (global.asp is run each time any page is > >>> called). > >> > >> Not really. Global.asp contains code for certain events: > >> application_onstart, application_onend, session_onstart and > >> session_onend. > > > > Global.asp or Global.asa? > > > > Oops. I kept mentally changing that to asa. > > Victor, are you talking about an include file called Global.asp? > > Show us the code so we can intelligently answer your question. Let me put it another way - when a .ASP page is called, I understand that the entire page is compiled even if a subroutine or function or piece of code isn't used. So, when an ASP page is COMPILED (NOT run), are database connections verified or established even if it's not called? For example, if I had this code: If 1=2 Then ' ### This will never be called.becauae 1 <> 2. ' ### Connect to Access Database - this will never be called strAccessDB = "/database/my6MegAccessDatabase.mdb" accessdb = server.mappath(strAccessDB) strconn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & accessDB & ";" Set conn = Server.CreateObject("ADODB.Connection") conn.open strconn End If Even though the above routine is never called, will it still be compiled, and a database connection established, when the page it is on is called? I suspect - and I'm looking for verification/documentation of this - that database connections are established/verified at COMPILE time (NOT runtime). If that's the case I may use a Server.Execute to only compile the code when needed. Victor wrote:
> Let me put it another way - when a .ASP page is called, I understand True> that the entire page is compiled even if a subroutine or function or > piece of code isn't used. > > So, when an ASP page is COMPILED (NOT run), are database connections No> verified or established even if it's not called? Show quote > Yes> For example, if I had this code: > > If 1=2 Then ' ### This will never be called.becauae 1 <> 2. > ' ### Connect to Access Database - this will never be called > strAccessDB = "/database/my6MegAccessDatabase.mdb" > accessdb = server.mappath(strAccessDB) > strconn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & > accessDB & ";" Set conn = Server.CreateObject("ADODB.Connection") > conn.open strconn > End If > > Even though the above routine is never called, will it still be > compiled, > and a database connection established, when the page it is No. Compiling does not involve executing the code. Compiling just> on is called? translates it to machine-executable code. Think about why database connection problems are only caught at runtime: never at compile time. For example: supply a non-existant database in your connection string: that will not be caught at compile time will it? Use your above if statement to verify this. > No. Code is only executed at runtime (which is why it is called> I suspect - and I'm looking for verification/documentation of this - > that database connections are established/verified at COMPILE time > (NOT runtime). "runtime"). > If that's the case I may use a Server.Execute to only Depending on what the code is, that may be what you want to do anyways.> compile the code when needed. -- Microsoft MVP -- ASP/ASP.NET Please reply to the newsgroup. The email account listed in my From header is my spam trap, so I don't check it very often. You will get a quicker response by posting to the newsgroup. "Bob Barrows [MVP]" wrote...
> Victor wrote: O.K., thanks Bob, this is exactly the info I was looking for!: > > and a database connection established, when the page it is > > on is called? > > No. Compiling does not involve executing the code. Compiling just > translates it to machine-executable code. Think about why database > connection problems are only caught at runtime: never at compile time. > For example: supply a non-existant database in your connection string: > that will not be caught at compile time will it? Use your above if > statement to verify this. Vic "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message No, you are describing global.ASA.news:ujeMZlOzGHA.4232@TK2MSFTNGP05.phx.gbl... > Victor wrote: > > I've got a website that is very fast. I just added a subroutine in > > the file global.asp (global.asp is run each time any page is called). > > Not really. Global.asp contains code for certain events: > application_onstart, application_onend, session_onstart and session_onend. > Where did you put your initialization code? Global.ASP is MY code. |
|||||||||||||||||||||||