Skip to main content
Inspiring
November 28, 2012
Question

Clear Template Cache Now button in CF10 admin

  • November 28, 2012
  • 1 reply
  • 2708 views

Hi folks,

I'm running CF10 on RHEL6.1 and I was just wondering if the "Clear Template Cache Now" button is supposed to delete cached class files that are created if you have the "Save class files" checkbox checked?

I was looking in my servers /WEB-INF/cfclasses directory and after clicking the button the files were still all there.

I had a very frustrating problem where ColdFusion managed to cache the template as a file not found error, and despite clicking all clear buttons and restarting CF the error would still be displayed every time I tried to browse the template. In the end the only thing I could do was ssh into my server and manually delete the class files. Once it cached the file this worked as expected.

Cheers,

Simon

This topic has been closed for replies.

1 reply

Inspiring
November 28, 2012

I'm running CF10 on RHEL6.1 and I was just wondering if the "Clear Template Cache Now" button is supposed to delete cached class files that are created if you have the "Save class files" checkbox checked?

No, that's not what the button does.  It clears the cached "templates" (which is a very poor way of describing the compiled classes ColdFusion executes) from memory, not the file system.

If you don't want those files accumulating in the cfclasses dir, switch off the setting to save them ("Save Class Files"). In my experience, there is very little benefit in saving them, and actually causes slightly performance degradation on large sites on Windows, because Windows struggles to manage directories with more than about 1000 files in it (this is anecdotal experience).

--

Adam

Charlie Arehart
Community Expert
Community Expert
November 28, 2012

I’d concur with Adam’s first point (the “clear template cache” does only clear from memory).

But I would respectfully disagree with the second.

There are times when save class files can indeed be very for performance. And the problems with disk contention (the “1000 files” reference) could similarly have a different root cause to be solved, rather than just turning off save classes. (And I don’t just mean general disk i/o issues, but specifically with respect to CF, and potential problems of excessive loading of files form the saved classes, possibly caused by an undersized template cache. Too much to elaborate here.)

Bottom line: it’s not a good general rule of thumb to “always turn off save class files”, but I do understand that many have come to believe it and share it when they think it may help. More analysis is needed to decide what’s best for a given site. That’s the sort of troubleshooting help I offer as an independent consultant, I’ll add. But I’m not fishing for work here.

Finally, Simon, as for the saved class file causing problems, here’s a possibility: could it be that something (a version control system, or FTP of a file to the server) might have caused the CFML source file’s date modified to be older than the saved class file? I have seen cases where that alone can cause a problem, where CF does not update the saved class file because it doesn’t see itself being “older” than the source. I’d blogged about it when I first found it in 2002 (as of CF 6). I’ve not gone back to test it since then, but you might want to consider what I wrote there: http://cfmxplus.blogspot.com/2002/11/alert-when-cf-will-fail-to-auto.html

Hope that’s helpful.

/charlie

/Charlie (troubleshooter, carehart. org)
Inspiring
November 28, 2012

No prob disagreeing Charlie, but you are being a bit patronising about it.

It's not a ColdFusion issue, it's just that Windows does struggle doing directory scans (which it needs to do to locate the class files when it needs to load one) if the directory has more than 1000-odd files in it.  It's almost detectable "with the naked eye".  So, anyhow, it doesn't matter about doing CF tuning, as it occurs at a level lower than CF / Java operates at.

That said, I stopped doing this sort of thing (tuning etc) a few years back, so I've not checked where Windows is at now with this... I don't think I've used a Windows server more recent that Win 2003. Maybe it's been fixed.

*nix, on the other hand, does not have this problem at all.

I have not experienced a production Windows server that runs faster with class files saved than it does without, and one can get "unexpected results" with code compilation in a dev enviroment if the class files are being saved (admittedly this is rarer on more recent versions of CF in my experience). So on the whole, it's a detrimental setting to use on Windows, I think.

The one thing that saving the files does give is that app start-up is faster as the source code doesn't need to be recompiled, but I think the benefit there is outweighed by the other issues above.

Charlie, YMMV, but I have a reasonable amount of mileage on this as well ;-)

Anyway, it's good to get a selection of advice from different people. If just to muddy the waters.

--

Adam