Sunday, 15 April 2012

Browser cache effect on coldfusion login -



Browser cache effect on coldfusion login -

i have code has been in production environment past 2 years no issues, lastly week our hosting company downwards 2 days, , when server got online, our application started having particular issue.

this issue when seek login, bring login page no errors. submitted troble ticket , asked clear browser cache. cleared cache , application started working again.

is there no other way resolve issue without clearing browser cache?

i have tried several method, have used

<meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate" /> <meta http-equiv="pragma" content="no-cache" /> <meta http-equiv="expires" content="0" />

and used

<cflocation url="index.cfm" addtoken="yes">

please see code application.cfc

<cfcomponent> <cfset this.name = "some_app"> <cfset this.applicationtimeout = createtimespan(0,9,0,0)> <cfset this.clientmanagement= "yes"> <cfset this.clientstorage = "registry"><!--- formally cookie, changed registry, no alter ---> <cfset this.loginstorage = "session" > <cfset this.sessionmanagement = "yes"> <cfset this.sessiontimeout = createtimespan(0,4,0,0)> <cfset this.setclientcookies = "yes"> <cfset this.setdomaincookies = "yes"> <cfset this.scriptprotect = "all"> <cfset this.datasource = "some_dsn"> <cffunction name="onapplicationstart" output="false"> <cfset application.scriptprotect = "all"> <cfset application.sessions = 0> <cfset application.surportmail = "support@some_app.com"> <cfset application.site.url = "http://some_app.com/"/> <cfset application.com.employee = createobject("component","com.user.employee").init()/> <cfset application.com.appraisal = createobject("component","com.appraisal").init()/> <cfset application.com.security = createobject("component","com.system.login").init()/> <cfset application.com.log = createobject("component","com.adexfe.portal.system.log").init()/> <cfset application.com.temp = createobject("component","com.adexfe.portal.temp").init()/> <cfset application.com.util.security = createobject("component","com.adexfe.util.security").init()/> <cfset application.com.security.url = application.site.url/> </cffunction> <cffunction name="onapplicationend" output="false"> <cfargument name="applicationscope" required="true"> </cffunction> <cffunction name="onrequeststart"> <cfargument name="requestname" required=true/> <cflock type="exclusive" scope="session" timeout="10"> <cfparam name="session.islogin" default="false" type="boolean" /> <cfparam name="session.userinfo" default="" /> </cflock> <cflock type="readonly" scope="session" timeout="40"> <cfset request.islogin = session.islogin> <cfset request.userinfo = session.userinfo> </cflock> <!--- check login here ---> <cfif not request.islogin , listlast(cgi.script_name,'/') neq "login.cfm" , listlast(cgi.script_name,'/') neq "forget.cfm"> <cflocation url="login.cfm" addtoken="no"> </cfif> <cfset application.com.security.url = application.site.url/> <cfset request.security = application.com.util.security/> <cfparam name="url.bp" default="#request.security.urlencrypt('bp=home')#"/> <cfset url.bpr = url.bp/> <cfif listfirst(url.bp,'=') eq 'h'> <cfset request.aurl = request.security.urldecrypt(listlast(url.bp,'='))/> <cfelse> <cfset request.aurl.bp = url.bp/> </cfif> <cfset request.aurl.bp = replace(request.aurl.bp,'.','/','all')> </cffunction> </cfcomponent>

login.cfm code:

<html> <head> <title>login</title> <link rel="icon" href="favicon.ico" type="image/x-icon"> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> <link href="assets/css/reset.css" rel="stylesheet" type="text/css" /> <link href="assets/css/login.css" rel="stylesheet" type="text/css" /> <meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate" /> <meta http-equiv="pragma" content="no-cache" /> <meta http-equiv="expires" content="0" /> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr><td width="50%" align="right"><br /> <img src="assets/img/logo-b.jpg" width="445" height="164" /></td> <td><span class="label"> <img src="assets/img/comp_logo.gif" vspace="100" hspace="50" /></span></td></tr> </table> <cfform name="login"> <table width="300" border="0" align="center" > <tr><td nowrap class="label"> email:</td> <td><cfinput class="in" name="username" message="valid email address required please" type="text" required="yes" /></td></tr> <tr><td height="41" class="label">password:</td> <td><cfinput class="in" name="password" style="color:red;" required="yes" type="password"/></td></tr> <tr><td height="41">&nbsp;</td> <td><input type="submit" value="login" class="sub"/><input name="captcha" value="" type="hidden"></td></tr> <tr><td>&nbsp;</td> <td><a href="forget.cfm">forget password?</a></td></tr> </table> </cfform> <cfoutput> <cfif structkeyexists(form,'captcha')> <!---login user info ---> <cfset s = createobject("component","com.system.security").init(false,false)/> <cfset l = createobject("component","com.system.login").init()/> <cfset l.url = application.site.url/> <cfset l.signin(form,s)/> <cfif not l.islogin> <div align="center" style="color:##f00; font-weight:bold; text-align:center;">#l.errmsg#</div> <cfset application.com.log.writeloginattempt(form.username)/> <cfelse> <!--- set session ---> <cflock type="exclusive" scope="session" timeout="30" throwontimeout="yes"> <cfset session.islogin = true> <cfset session.userinfo = application.com.employee.getemployee(l.userinfo.employeeid)/> </cflock> <cfset application.com.log.writeloginsuccess(form.username,l.userinfo.employeeid)/> <cflocation url="index.cfm" addtoken="no"> </cfif> </cfif> </cfoutput> </body> </html>

thank you

you can clear application variables on server if utilize these commands, can utilize structclear() if want reset of variables , restart application. speaking 1 time application variables set remain persistent in memory until application restarted.

these commands restart application.

<cfscript> applicationstop(); </cfscript> or <cfset applicationstop()>

after variables have been cleared can remove line of code , should resolve caching issue.

coldfusion browser-cache coldfusion-9

No comments:

Post a Comment