So, I have a friend who hosts a web site over at an ISP that will remain nameless for now. I've never used them as an ISP for my own sites, but from my experience with them, they are a pretty darn good host.
However, something happened today I felt I should warn others about. This is not meant to be an attack on them, but just to clear up a misconception they have - and others may have as well.
The ISP has a nice control panel that allows you to admistrate various aspects of your web site. One of things they allow for is the creation of CF Mappings. This is pretty nice since normally this requires CF Admin access. However, I noticed their UI didn't let me create a mapping to the web root for the web site. It only allows mappings to sub folders. When I questioned the ISP about it, they told me that when CF starts up, it reads all the files in a mapping and that a mapping to the web root could be a performance issue.
I'm not sure if others have heard this as well, but just so it is clear, this is not true. Mappings only work as an alias. The folders they point to will not be scanned upon CF startup.
p.s. The ISP is investigating this issue and promised to get back to me. As I said before, I have a good impression of this ISP so hopefully they will change their policy!
Archived Comments
I've recently been introduced to the pain of customTags and their required mappings for CFMODULE and CFINCLUDE if they're in the CustomTags directory.
Is there a good way to avoid having users have to use mappings if they put the custom tag in another directory than the template? I know there are some methods of using the ServiceFactory, but not confident that's the right way to go.
You mean "required" if _not_ in the custom tags folder.
Frankly, I think mappings are very important, and I (normally) recommend AGAINST just using the custom tag folders.
The biggest reason is name resolution. If you have 2 apps on the same serer using a custom tag, "secure.cfm", than it is possible CF will get confused by which to call. Using a mapping removes this confusion completely.
Yes, absolutely right. Right now, when I send buyers my app, I simply include info on how to set up a mapping, but leave the custom tag in the same directory as the calling template. This way at least, they can have an instant setup. I would like to be able to have the mappings auto-created though...along with DSN creation. Just to make it painless to install the app.
Clearly the ISP is mistaking a regular mapping for a custom tag mapping?
Uh... what's the difference? (Sorry for the dumb question)
Regular mappings are as Raymond said, aliases.
CustomTag mappings however, will load *.cfm files into memory. That will definitely have a performance issue, especially if you make the CustomTag mapping '/' -- however, depends on how many *.cfm files, etc.
Todd, respectfully I disagree with you. CF doesn't load the files for custom tags when it starts up.
Ok? What does it do then? Why wouldn't it? It's a 'Global' CustomTag? I've been lead to believe that it gets loaded into memory. So, perhaps that was CF5-era.
It doesn't do anything at startup, except to generate a list. When you call cf_foo, it will then check each folder for foo.cfm. Once it finds it, it caches the location.
Ok, so.. that clears that up. I'd still see somewhat of a performance hit if someone made '/' a CustomTag mapping. Do you at least agree with that?
No, I don't. I only see an issue if you have a _large_ number of CT paths, and I mean a large number, and even then, it is only an issue the first time you call cf_foo. Once CF finds foo.cfm, it remembers it.
I think you're missing what I'm trying to stress. If you make '/' a CustomTag path, it basically goes after _ALL_ CFM files in '/' and has to remember the location for each.
Let's not forget the dangers of what might happen if there's 2 sql_whatever.cfm files within that subtree of '/' and also, the dangers if one of them happens to be different than the other.
Realistically, if a site only has foo.cfm available, we're all in trouble when bar.cfm is found.
So, myths debunked:
* CustomTags are not loaded into memory, their location is.
What do you mean "goes after"? It doesn't do that. CF only uses custom tag paths when you call a custom tag. Ie, when you run cf_foo. Even then, it does a simple file search for foo.cfm.
As for your second paragraph - that's a danger - yes - but it has nothing to do with performance. It's just how CF handles custom tags. Thats why I tell folks to use cfmodule.
I'm not sure what your last paragraph means.
Ok, so.. basically you're saying that with '/' marked as a CustomTag path, it doesn't do anything until <CF_Whatever> is called.
Once <CF_Whatever> is called then it looks locally (Same location as the calling file), looks globally (CustomTag path) and wherever it finds it, it THEN caches the path to that location for future reference?
Yep, that's why you need to restart CF if you move a CT after you have called it.
Frankly, I never use CT paths anyway, I almost always use cfmodule.
Ok, I'm cleared up now. Shame, I used to view the CustomTags path as magic. Now, with the help of jedimaster, I see there is no spoon. Er.. wait.
Anyway, thanks for the clarification. Pre-CFMX coding, I use modules/local custom tags all over the place rather than global CustomTags.
I'm still trying to get work to admit that we're on CFMX and that it's safe to use CFCs and that we won't have anymore CF5 customers / requirements.
Persoanlly I just make a solder off my root directory called custom_tags and use cfmodule to call the template with the relative path. I can't stand jerking around with mappings and what not and persoanlly ir makes it alot easier to move the application from one server to the other. All I have to do is copy the entire folder.
To answer the previous question about alternatives to mappings -- I strongly suggest using CFIMPORT. I used to do the "flat directory" thing to be able to use CF_ syntax (I never liked CFMODULE), but CFIMPORT makes your code even cleaner, IMO, and you can put your custom tags in nested directories that make logical sense for your development easily.
I think I'm confused... you're using CFIMPORT to bring in a custom tag? How?
And what's wrong with using CFMODULE?
There's nothing wrong with CFMODULE, per se. My two main problems are that 1) I find myself having lots of custom tags with an attribute called NAME -- that just doesn't work with CFMODULE (and yeah, I understand that it's perhaps not the best design choice if I ever need to share my code), and 2) I think CFMODULE is just ugly code, especially if you start having nested custom tag calls and then throw in tags with end-tags.
CFIMPORT is made to bring in custom tag libraries (CFML or JSP) -- read the docs. I've become a big fan.