Created
August 6, 2012 19:54
-
-
Save nicklepedde/3277959 to your computer and use it in GitHub Desktop.
Perfect Reload Sample code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="OnApplicationStart" output="false"> | |
<cfset application.initTime=now()> | |
</cffunction> | |
<cffunction name="onRequestStart" returnType="boolean" output="true"> | |
<cfargument type="String" name="targetPage" required="true" /> | |
<cfif structKeyExists(url,"reloadApp")> | |
<cfset OnApplicationStart()> | |
</cfif> | |
<cfset request.AssetCacheString=dateformat(application.initTime,"yyyymmdd")&timeformat(application.initTime,"hhmmss")> | |
<cfreturn true> | |
</cffunction> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<link href="/css/Site.css?#request.AssetCacheString#" rel="stylesheet" type="text/css" /> | |
<script src="/Scripts/site.js?#request.AssetCacheString#" type="text/javascript"></script> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="OnApplicationStart" output="false"> | |
<cfset application.SomeCFC=createObject("component","com.utils.something").init()> | |
<cfset application.OtherCFC=createObject("component","com.utils.otherthing").init(webkey="a_Value")> | |
</cffunction> | |
<cffunction name="onRequestStart" returnType="boolean" output="true"> | |
<cfargument type="String" name="targetPage" required="true" /> | |
<cfset request.ServerTime=now()> | |
<cfreturn true> | |
</cffunction> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfset adminObj = createObject("Component", "cfide.adminapi.administrator")> | |
<cfset adminObj.login("cfadmin_password")> <!--- change to use your CF Admin password ---> | |
<cfset rtService = createObject("component", "cfide.adminapi.runtime")> | |
<cfset rtService.clearTrustedCache()> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="onRequestStart" returnType="boolean" output="true"> | |
<cfargument type="String" name="targetPage" required="true" /> | |
<cfif structKeyExists(url,"reloadApp")> | |
<cfset OnApplicationStart()> | |
<cfobjectcache action="clear"> | |
</cfif> | |
<cfset request.ServerTime=now()> | |
<cfreturn true> | |
</cffunction> | |
<!--- Some other file ---> | |
<cfquery datasource="xyz" cachedwithin="#createTimeout(0,0,5,0)#"> | |
SELECT * | |
FROM everything | |
</cfquery> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="onRequestStart" returnType="boolean" output="true"> | |
<cfargument type="String" name="targetPage" required="true" /> | |
<cfset request.queryTimeout=createTimeout(0,0,5,0)> | |
<cfif structKeyExists(url,"reloadApp")> | |
<cfset OnApplicationStart()> | |
<cfset request.queryTimeout=createTimeout(0,0,0,0)> | |
</cfif> | |
<cfset request.ServerTime=now()> | |
<cfreturn true> | |
</cffunction> | |
<!--- Some other file ---> | |
<cfquery datasource="xyz" cachedwithin="#request.queryTimeout#"> | |
SELECT * | |
FROM everything | |
</cfquery> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfparam name="server.reloadTime" default="#now()#"> | |
<cffunction name="OnApplicationStart" output="false"> | |
<cfset application.initTime=now()> | |
</cffunction> | |
<cffunction name="onRequestStart" returnType="boolean" output="true"> | |
<cfargument type="String" name="targetPage" required="true" /> | |
<cfif structKeyExists(url,"reloadApp")> | |
<cfset server.reloadTime=now()> | |
</cfif> | |
<cfif application.initTime lt server.reloadTime> | |
<cfset OnApplicationStart()> | |
</cfif> | |
<cfreturn true> | |
</cffunction> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfparam name="server.reloadTime" default="#now()#"> | |
<cffunction name="OnApplicationStart" output="false"> | |
<cfset application.initTime=now()> | |
<!--- Load up some application variables and cache objects ---> | |
<cfset application.SomeCFC=createObject("component","com.utils.something").init()> | |
<cfset application.OtherCFC=createObject("component","com.utils.otherthing").init(webkey="a_Value")> | |
</cffunction> | |
<cffunction name="onRequestStart" returnType="boolean" output="true"> | |
<cfargument type="String" name="targetPage" required="true" /> | |
<cfif structKeyExists(url,"reloadApp")> | |
<cfset server.reloadTime=now()> | |
</cfif> | |
<cfif application.initTime lt server.reloadTime> | |
<cflock scope="Application" timeout="10" type="Exclusive"> | |
<cfif application.initTime lt server.reloadTime><!--- check again in case the app has been reloaded since the lock was released ---> | |
<!--- Clear the template cache to pick up on changed templates (this clears the trusted cache) ---> | |
<cfset adminObj = createObject("Component", "cfide.adminapi.administrator")> | |
<cfset adminObj.login("cfadmin_password")> <!--- change to use your CF Admin password ---> | |
<cfset rtService = createObject("component", "cfide.adminapi.runtime")> | |
<cfset rtService.clearTrustedCache()> | |
<!--- Clear out all cached queries ---> | |
<cfobjectcache action="clear"> | |
<!--- Reload the cached applciation items ---> | |
<cfset OnApplicationStart()> | |
</cfif> | |
</cflock> | |
</cfif> | |
<!--- format last reload date for use with asset URLs to have them appear new and force the browser to geta fresh copy. ---> | |
<cfset request.AssetCacheString=dateformat(application.initTime,"yyyymmdd")&timeformat(application.initTime,"hhmmss")> | |
<cfreturn true> | |
</cffunction> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="onRequestStart" returnType="boolean" output="true"> | |
<cfargument type="String" name="targetPage" required="true" /> | |
<cfif structKeyExists(url,"reloadApp")> | |
<cfset OnApplicationStart()> | |
</cfif> | |
<cfset request.ServerTime=now()> | |
<cfreturn true> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment