Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thanks very much guys. You confirmed I am not going completely crazy!!
Charlie, something strange was definitely happening with the class files. I found some with owner/group permissions of root:root when my coldfusion instance runs under a cfusion user.
Before I realised it was saved class files caching the error, i had been trying to edit the templates on the server (putting in aborts to see if it would even get in to the templates), I would have thought that should trigger the template to be reloaded and a new class to be saved??
Cheers,
Simon
Copy link to clipboard
Copied
Before I realised it was saved class files caching the error, i had been trying to edit the templates on the server (putting in aborts to see if it would even get in to the templates), I would have thought that should trigger the template to be reloaded and a new class to be saved??
You don't have "Trusted Cache" switched on, do you? If you do, the source code is never checked for changes, and CF will simply use whatever it's already got compiled.
--
Adam
Copy link to clipboard
Copied
Hey Adam,
No I didn't have trusted cache turned on. I had save class files, component cache and cache template in request turned on. So I'd have expected it to check for changes with that combo?
Maybe the fact that some of the cached class files some how were owned by root meant CF couldn't overwrite it even though it detected a change??
Cheers,
Simon
Copy link to clipboard
Copied
Yep, those settings should be fine; and - yes - I reckon the file ownership thing would cause problems.
How is it that some of the saved files have different ownership? This sounds like something that ought to be looked into...
--
Adam
Find more inspiration, events, and resources on the new Adobe Community
Explore Now