Skip to main content
Inspiring
November 13, 2007
Answered

CF Pages SLOOOOOW (basically never run)

  • November 13, 2007
  • 3 replies
  • 474 views
Returning to CF programming after 5 years away from programming entirely, I was able to write four pages (displaying and updating records in SQL Server) which were working great until I set up an Application.cfm page to allow for a login screen. Then they all ground to a halt (e.g. 15 minutes, after which I gave up and cancelled them). This happened with CF 5, so I just installed CF8 (developer version) in hopes of fixing it, but that doesn't run at all yet, as described in another posting I just did (JNDI port 2930 for server Coldfusion not active). This is probably not a conflict with CF5, since I uninstalled that before attempting to install CF8.

Yesterday and this morning, when CF5 was still installed, whenever the pages hung and I checked Performance in Task Manger, it was always at 100%. The problem must be something in Application.cfm since all I had to do is rename it to xApplication.cfm, and the pages worked fine just as they had before. I did this on two different computers with the same results - both the problem and the 'fix' to it be renaming Application.cfm (If it matters, one of the computer has 500MB of RAM; the other had 1GB; both are running Windows XP Professional).

A very interesting result occurred if I entered a page other than the login page into the brower's address bar, then renamed Application.cfm WHILE THE PAGE WAS STILL TRYING TO LOAD (which it should not allow me to do, right, if Application.cfm was in use?). What happened was that the browser was suddenly redirected to the login page, just as Application.cfm instructed it to do if Session.LoggedIn was false. So it must have been running Application.cfm, or how would it have known to do that?

Your help with this problem (which would probably happen with CF8, too, is my guess) would be greatly appreciated!

My Application.cfm page (which I mostly copied from Programming ColdFusion by O'Reilly, p. 204), is shown after the double dashed line below. The 'cfoutput' tags were intended to show me how far it got, and strangely, numbers '1' and '2' were working at one point yesterday, then stopped working for some reason; the 'cfouput' of cgi.script_name and Session.LoggedIn were added later, and never have worked. As you can see, some sections of code, including 'cflock' tags, are currently commented out, but that didn't help.
=================================================================================
<cfapplication name="Reporters" sessionmanagement="Yes" setclientcookies="Yes" sessiontimeout="#CreateTimeSpan(0,0,30,0)#" applicationtimeout="#CreateTimeSpan(0,0,30,0)#">

<cfoutput>'1'</cfoutput>

<cflock scope='Session' type='Exclusive' timeout='10'>
<cfparam name='Session.LoggedIn' Default='False'>
</cflock>

<cfoutput>#Session.LoggedIn#</cfoutput>
<cfoutput>#cgi.script_name#</cfoutput>
<cfoutput>'2'</cfoutput>

<!-- If the user isn't logged in or they aren't currently on the login page, send them to the login page -->
<!--<cflock scope='Session' type='Readonly' timeout="10"> -->
<cfif not Session.LoggedIn>
<cfoutput>'3'</cfoutput>
<cfif cgi.script_name is not 'Reporters/ReporterLogin.cfm'>
<cflocation url='/Reporters/ReporterLogin.cfm'>
</cfif>
</cfif>
<!-- </cflock> -->

<cfoutput>'4'</cfoutput>

<!-- Reset the CFID and CFToken cookies to expire session and client variables after the user's browser closes
<cfif IsDefined('Cookie.CFID') and IsDefined('Cookie.CFToken')>
<cfcookie name='CFID' value='#Cookie.CFID#'>
<cfcookie name='CFToken' value='#Cookie.CFToken#'>
</cfif>
-->

<!-- If Application variables other than the name of the app are used, set them here (with CFLOCK) -->
This topic has been closed for replies.
Correct answer SafariTECH
I think you may be in a infinite loop with your login verification. It is the number 1 reason for the symptoms you are seeing.

Try changing this portion:
<cfif cgi.script_name is not 'Reporters/ReporterLogin.cfm'>
<cflocation url='/Reporters/ReporterLogin.cfm'>
</cfif>

to:
<cfif cgi.script_name contains "ReporterLogin.cfm">
<!--- do nothing --->
<cfelse>
<cflocation url="/Reporters/ReporterLogin.cfm" addtoken="No">
</cfif>

and see if it makes a difference.



BTW, I suggest using double quotes in your CF tag variables - single quotes sometimes cause issues or can be ignored sometimes.

3 replies

PeytonTAuthor
Inspiring
November 14, 2007
You got the answer. Once I switched all the single quotes to double quotes, the status bar at the bottom of the browser showed the page getting called again, instead of just the progress bar as it had done previously. And there's no need for me to test using CONTAINS instead of EQ since, now that you've pointed it out, it's obvious that my mistake was leaving off the initial '/' in the <cfif> clause, causing it to evaluate again and again as false, since ;the value of cgi.script does contain an initial '/'. Many thanks for you help, and I'll mark your contribution as the answer!
SafariTECHCorrect answer
Inspiring
November 14, 2007
I think you may be in a infinite loop with your login verification. It is the number 1 reason for the symptoms you are seeing.

Try changing this portion:
<cfif cgi.script_name is not 'Reporters/ReporterLogin.cfm'>
<cflocation url='/Reporters/ReporterLogin.cfm'>
</cfif>

to:
<cfif cgi.script_name contains "ReporterLogin.cfm">
<!--- do nothing --->
<cfelse>
<cflocation url="/Reporters/ReporterLogin.cfm" addtoken="No">
</cfif>

and see if it makes a difference.



BTW, I suggest using double quotes in your CF tag variables - single quotes sometimes cause issues or can be ignored sometimes.
Inspiring
November 13, 2007
Where do you have coldfusion installed in your pc?
cf5 when i used it has so many problems it wasnt funny. I imagine the cflock it should be necessary with cf8 or even with cf5 if multithreading on the server is checked. Try using double quotes " that may work