ColdFusion Server CFC Caching Issue
Asked Answered
M

8

12

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 cfc 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!

Magnitude answered 11/2, 2010 at 21:43 Comment(8)
Are they in your application scope? Also do you have "Save class files" checked under Server Settings > Caching?Viand
Are you saving them to any persistent scope? Session/server/etc.?Exeter
Check Admin > Data & Services > Web Services and see if the cfcs are registering themselves as web services, if so delete them from that screen and see if that helps.Viand
None of them are registered as web services. I am however saving some of my CFCs to application and session scopes. What can I do to get around this?Magnitude
@Gavin Are you working on run-of-the-mill CFCs or web service CFCs?Angloirish
I'm not running web service CFCs, so its a run-of-the-mill CFC.Magnitude
I can't test this now but try making a small cfm with one line <cfset OnApplicationStart()> And see if that reloads them, if it does I will move this to an answerViand
This should be helpful: #3119619Canteen
A
10

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.

Airsick answered 18/2, 2010 at 18:54 Comment(1)
this has been giving me headaches for so long. i didn't realize that putting something in application scope actually saves the code. i thought it would just save the object's metadata. thanks!Lodgings
L
1

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.

Ljoka answered 11/2, 2010 at 21:58 Comment(1)
That's exactly what I need! But I'm running CF8. Its not supported in that version :(Magnitude
P
1

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.

Peplum answered 11/4, 2013 at 13:54 Comment(0)
C
0

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

Caching > Trusted Cache

Caching > Save class files

Commutable answered 11/2, 2010 at 23:21 Comment(0)
L
0

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

Landseer answered 12/2, 2010 at 21:31 Comment(1)
No, the functions are not called onApplicationStart.Magnitude
R
0

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!!!

Rebec answered 15/2, 2010 at 17:4 Comment(1)
Thank you for the response. I tried it but didnt work. This has only typically worked for my .cfm files in the past anyway. I tried enabling then disabling the cache options as well, no joy :(. It almost sounds like its going to have to be a constant annoyance of restarting CF application server until my company decides to upgrade to CF9 or later.Magnitude
R
0

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>
Rafaelarafaelia answered 4/3, 2010 at 18:36 Comment(0)
H
0

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.

Haveman answered 28/4, 2010 at 12:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.