A little bit ago I sat in the session "End to End Performance Tuning", which was a great session. One of the tips mentioned was the use of trusted cache on production systems. One of the problems with this though is that you need to clear the template cache for each and every little change. What folks tend to forget is that the Admin API has support to clear individual files. I blogged about this last year (at CFUN I think) and wrote up a quick little script to show an example of it. This came up again during the session so I thought I'd work a bit on the script and make it a bit more presentable in the ColdFusion Admin.
Take the script attached to this template and put it in your ColdFusion Administrator folder. Put it in a subfolder named anything you want, I used cacheclearer. Then edit custommenu.xml to add a link:
1 <menuitem href="cacheclearer/" target="content">Cache Clearer</menuitem>
Then hit up your Admin and you can run the utility. You can enter a CFM/CFC to clear or a folder and all CFM/CFCs under it will be clearer.
Comment 1 written by James Moberg on 19 June 2008, at 5:07 PM
This appears to be a CFMX 8-Only method. Can this be modified to work with CFMX 6 or 7? If so, is there any easy way to integrate it?
Comment 2 written by Raymond Camden on 19 June 2008, at 5:09 PM
Comment 3 written by Casey on 19 June 2008, at 8:42 PM
By the way, the image does not work.
Comment 4 written by Gary Fenton on 20 June 2008, at 4:00 AM
For the past month I've turned off trusted cache and haven't noticed any performance changes. I suspect it's only noticable if your server is running close to its limit, then it may shave a few milliseconds off each request - which adds up if you have lots of requests per second.
Comment 5 written by Raymond Camden on 20 June 2008, at 7:44 AM
Comment 6 written by James Moberg on 20 June 2008, at 9:09 AM
Is it possible to add a function to "onrequestend.cfm" to take a parameter (URL variable, IP address, browser agent, time window) and then determine which templates were recently used to generate the current page and clear them from the trusted cache?
If it is possible, would this method be advisable?
Comment 7 written by Scott P on 20 June 2008, at 2:51 PM
Comment 8 written by Charlie Arehart on 21 June 2008, at 9:35 AM
Of course, if the template cache is too small, then the value of having trusted cache enabled may be diminished, as the cache is thrashed removing requests and recompiling them.
Indeed, when Gary says he experienced no difference by enabling it, I'd wonder if that was the issue (unless it's simply that he didn't have enough requests on his server to notice any benefit from the i/o saved, which may be small per request but would increase in total value with more requests.)
@James, I don't understand what you're asking. What connection would you expect "recent use" to have on whether templates should be cleared from the cache? All that matters is whether the template has been *edited*, which is why tools that use the filewatcher gateway (as pointed to by Scott P) would be the way to go.
Comment 9 written by James Moberg on 21 June 2008, at 7:16 PM
For example if a simple template was updated, it would be nice to be able to pass a parameter or something and have an "onrequestend" function determine which templates were used in the generation of the page and delete them from the trusted cache. This would save a trip to the CFAdmin and requirement to find the templates that need to be deleted.
I looked at the solution offered by Scott P and the project states that ColdFusion 8 is a requirement... although I downloaded the project and the readme.txt has installation instructions for CFMX 6 & 7 but doesn't mention 8. I'm not sure if there a legitimate 8 requirement or whether it will it also work with 6/7.
I guess what frustrates me the most is reading an article and not knowing whether or not it will work on CFMX 7 because the writer takes it for granted that everyone is using 8. This has happened a couple of times in other forums and I find myself wasting time attempting to determine why something isn't working only to find that the developer uses new CF-8 only syntax or requires new hidden features not available in 7. I sometimes spend even more time trying to figure out a work-around to make it work. Sometimes I'm successful and other times I am not.
Comment 10 written by Scott P on 21 June 2008, at 9:56 PM
If you are on 7 then you will be stuck with clearing the entire cache - the same as clicking on the clear template cache button in the admin. You could set the code to do that part for you.
Comment 11 written by Raymond Camden on 22 June 2008, at 6:56 AM
Comment 12 written by James Moberg on 22 June 2008, at 8:44 AM
@Ray - I read the linked article and thought that all the magic was in the Admin API and set of CFCs that may have also been possible to work with CFMX7. I didn't know if this was just a couple of new scripts that were added or if is an internal java update that allows it to do it. Is it possible that these CF8 CFCs would also work in CFMX7 but are available only in CF8?
Some organizations I work with remain on CF5 and CFMX6 due to budget constraints and the fact that "it's not broken" and "doesn't need updating." This requires me to integrate scripts that work across as many versions as possible to ensure that I can upsell new features to them as no new CF8 features that I've mentioned have enticed them to upgrade yet.
Comment 13 written by Raymond Camden on 22 June 2008, at 8:53 AM
Comment 14 written by James Moberg on 22 June 2008, at 9:14 AM
Don't get me wrong, I'm using CF8 too and I know that the upgrade is a lot more than just the inclusion of already existing third-party tags and libraries. I've been following many of the book, articles and blogs since CF2/3 and now more than ever I have to filter what I'm reading to determine which version (and potential client) I can actually apply these new tips too. I really don't recall having to do before as most tips seemed to be CFML-specific and not version or vendor specific.
Comment 15 written by Charlie Arehart on 23 June 2008, at 9:50 AM
There are several dozen small (and some important) changes beyond the big things you hear talked about all the time.
Comment 16 written by Barbara ONeal on 12 July 2008, at 3:57 PM
I downloaded and placed the code on my server. I just ran inot an issue where is does't actually remove any of the class files. If i put in an individual file it says that it is going to clear it. But it still exist in the directory. So i thought hmmm i will just do the entire direcotry. Well that didn't work either. For example: C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\cfclasses then select clear file/folder It doesn't throw an error it just doesn't do anything.
Ideas?
Comment 17 written by Raymond Camden on 13 July 2008, at 9:10 PM
This utility doesn't clear the class files. Instead, it tells CF, "Hey, for these files, you need to check them on next execution to see if they need rebuilding."
Comment 18 written by Yaron Kohn on 10 November 2008, at 1:48 PM
I would suggest adding this line of code to the bottom of the page....It sets the "Last Page Visited" cookie like all the other admin pages.
<cfset cookie.CFADMIN_LASTPAGE_ADMIN = cgi.SCRIPT_NAME>
Comment 19 written by Raymond Camden on 10 November 2008, at 1:56 PM
Comment 20 written by Charlie Arehart on 23 January 2009, at 9:52 PM
Also, I would think this is a feature set that should be built into CF (or at least an admin interface to point to templates to clear manually). Have you made either suggestion as a feature request? It may be considered for Centaur, which would be awesome.
Comment 21 written by Raymond Camden on 24 January 2009, at 9:41 AM
I did file an enhancement request for this with Adobe (like 2 mins ago).
Comment 22 written by Charlie Arehart on 24 January 2009, at 10:05 AM
Really great to hear you've requested it of Adobe. Of course, if it gets in then one could argue that the need of a project is diminished, but since 9 is still in the future, and even then many may remain on 8 who would benefit, it seems worth it, sure.
Comment 23 written by Raymond Camden on 24 January 2009, at 11:39 AM
Comment 24 written by Eric P on 24 March 2009, at 11:57 AM
Is anyone aware of a way to check the state of the trusted cache toggle? I thought it'd be cool to deactivate the 'cache clearer' form when the trusted cache is toggled off.
Thanks again,
Eric P
Comment 25 written by Raymond Camden on 24 March 2009, at 4:29 PM
You can tell if the trusted cache is on with the Admin API. It may be cool to add that to my tool as a flag. "Are you sure you want to clear cache? Trusted cache isn't even turned on, Bozo."
Shall I add that?
Comment 26 written by Eric P on 30 March 2009, at 7:40 PM
By the way where is the Admin API documented?
Thanks,
Eric P
Ps. the lucky captcha I got to type was 'die'. (*shiver*)
Comment 27 written by Raymond Camden on 30 March 2009, at 7:49 PM
Comment 28 written by Raymond Camden on 2 April 2009, at 1:33 PM
I'll update the link in my guide soon.
Comment 29 written by Raymond Camden on 2 April 2009, at 1:35 PM
http://cacheclearer.riaforge.org
Comment 30 written by Vad on 16 September 2009, at 6:10 AM
I am promoting corrections to it but they do not seem to show up on the server.
I want to resort to clearing the Server cache so that my promoted code can take effect.
The CFAdmin production template was cached (Trusted Cache turned on). so wanna turn it off Trusted Cache and clear template cache.
So was wondering it will effect the main site?
ANY PRECAUTIONS, as this is for a production server?
Thanks
-Vad
Comment 31 written by Raymond Camden on 16 September 2009, at 6:45 AM
Comment 32 written by Vad on 16 September 2009, at 6:59 AM
Is what are the precautions to be mad if at all the server cache is to be cleared on CFMX admin?esp a production server.
I have the detailed issue i faced over here.
http://stackoverflow.com/questions/1429368/element...
Comment 33 written by Raymond Camden on 16 September 2009, at 7:01 AM
Comment 34 written by Vad on 16 September 2009, at 7:53 AM
I meant in CFAdmin/cache/templated cache
I think the template was cached (Trusted Cache turned on),
So I want to turn off Trusted Cache and clear template cache.
As it is Live, wanted to know if any precautions?
Comment 35 written by Raymond Camden on 16 September 2009, at 8:18 AM
Comment 36 written by Vad on 16 September 2009, at 8:33 AM
The form fields were in saved session variables and then stored in a SAVED form.
My error was in opening the saved form.
I corrected it and pushed the code.
So was hitting on the last option as to turn off Trusted Cache and clear template cache.
Now would the SAVED forms with the old session-id be gone?
[Add Comment] [Subscribe to Comments]