开发者

ColdFusion Server CFC Caching Issue

I develop coldFusion applications on my laptop with it's own ColdFusion 8 server with IIS which run on Windows Vista. I am having a rather annoying problem.

The problem is whenever I make any changes to my CFC's, it appears that unless I restart my ColdFusion Application server, the changes to my CFC's will not take effect unti I do so. Often times, I have to restart my whole machine because Windows can't restart the ColdFusion Application Server service. Is there a better way to reset the ColdFusion Server's cf开发者_运维问答c cache?

This is beginning to suck up a lot of time just having to restart every so often after I make a change. Any insight would be greatly appreciated!

Thank you!


I guarantee you are creating these as objects in some sort of persistent scope, eg: application, session scopes. What I generally do to avoid this problem during development is create a url parameter and check for that in the application.cfm/cfc file (or wherever you are creating the objects) and recreate the objects if that url parameter is detected.

Example:

<cfif NOT structKeyExists(application,"myObj") OR structKeyExists(url,"reinit")>
    <cfset application.myObj = createObject("component","path.to.cfc") />
</cfif>

of course you would need to do this with every object that you are having a problem with.


im not sure if this is in other versions of CF also but in CF9 you can do ApplicationStop() and it will reset the CFApplication and reload it.


Uncheck "Component cache" in CFAdmin --> Caching

Also check CFAdmin --> Mappings and make sure the CFC folder is pointing to the right one if any. Sometimes people clone their source code and don't change the mapping to the new folder.


In your Coldfusion Administrator, do you have either of the following enabled (checked)?

Caching > Trusted Cache

Caching > Save class files


Just asking the obvious: Are you calling these functions from onApplicationStart?


Maybe try the "Clear template cache" button under CF Admin > Caching.

This has happened to me before. I usually have to click the button several times for CF register the changed files.

Might also try unchecking everything under Caching as well. Note: Only do this for development machines!!!


If you must have caching in dev, you might do what I do:

First put a check for a URL flag to the top of your onRequest() method which will call the onApplicationStart() method:

<cfif IsDefined("URL.dev")>
    <cflock timeout="5" scope="Session" type="Exclusive">
        <cfif URL.dev EQ true>
            <cfset SESSION.debug = true />
        <cfelse>
            <cfset StructDelete(SESSION, "debug") />
        </cfif> 
    </cflock>
</cfif>

<cflock timeout="5" scope="Session" type="Readonly">
    <cfif IsDefined("URL.appreset") or IsDefined("SESSION.dev")>
            <cfset StructClear(SESSION) />
            <cfset onApplicationStart() />
        </cfif>
</cflock>   

This will fix most of your problems. However, if you have a problem in a class that you are loading, it won't get far enough to check for this flag. The solution I use for this:

Add the following to the bottome of your onError() method:

<cfif IsDefined("APPLICATION")>
      <cfset StructClear(APPLICATION) />
</cfif>

Finally, you want to check that the APPLICATION object exists and that each class you are declaring as part of the APPLICATION scope exists or you want to recall onApplicationStart(). To do this, add the following right below the first block of code at the top of onRequestStart():

<cfif not IsDefined("APPLICATION")
    OR not StructKeyExists(APPLICATION, "[ClassName1]")
    OR not StructKeyExists(APPLICATION, "[ClassName2]")
    ...>
    <cfset onApplicationStart() />
</cfif>


I had the exact same problem, sometimes I had to restart the machine if the changes would not reflect after starting the server the service manager.

What I do is, in (Administrator,Caching): 1. I unchecked all cache options 2. I set the text box values to "0" 3. I Keep the (Administrator,Caching) page open when developing, so that when I upload a change and it doesn't reflect, I just hit the "Clear Template Cache Now".

This is what is working for me on CF8, Built In Web Server, XP.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜