Reply to topic
application.cfm
cbsinet.com


Joined: 04 Oct 2004
Posts: 18
Location: Dunedin, FL
Reply with quote
I've been using ColdFusion for a couple months and I wanted to know if you know any good uses for the application.cfm or if there are problems/risks associated with it.

I have a feeling it basically just runs like a header include on each page.

I can set variables in it and I assume I can put common functions in it but I am worried about performance decreases by doing so.

Any tips you could offer would be appreciated.
byron
Forum Admin

Joined: 07 Mar 2004
Posts: 160
Location: Newark, DE, USA
Reply with quote
You are correct, it is actually processed on every page request, so you want to limit the amount of activity that may be page specific.

Good/Common uses are setting application vars, checking for a user's authentication, application includes (maybe like a session tracking application), and settng request variables.

You can also have multiple application.cfm within you're directory structure. CF server looks up the entired directory structure to the root of your web site from the directory where the called template resides to find an application.cfm file, the first one it gets to it will use.

A common directory struct with multiples would look like this

/
/application.cfm
/admin
/admin/application.cfm

So when you're in the admin directory, only the admin/app.cfm is being processed.

There is also the concept of onRequestEnd.cfm, that acts in the same manner. It's undocumented for the most part. I usually use it for testing and doing cfdumps of scoped variables for debugging.
loftboy
Forum Regular

Joined: 24 Jun 2004
Posts: 1129
Location: Colorado
Reply with quote
u pretty much have to run an Application.cfm page with any cfm site for it to work correctly. IF u feel u dont need it then u need to just do the site in straight html or actually now in xhtml
byron
Forum Admin

Joined: 07 Mar 2004
Posts: 160
Location: Newark, DE, USA
Reply with quote
You can create a site without the application.cfm, but you will lose a lot of functionality. Mainly session, client, application scoped variables. You should still have access to all tags and functions.
loftboy
Forum Regular

Joined: 24 Jun 2004
Posts: 1129
Location: Colorado
Reply with quote
sure u can but who in their right mind would do that?
lets just make good coding habits and say its REQUIRED
1st thing i make when making a new site

if u dont use it then you cant do any logging in or anything to do with sessions

also, this is one template that should always be capitalized. i know it sounds dumb but u'd be amazes how many ppl pull their hair out to find that they are on linux and need it to be a capital A

not to mention if u dont use Application.cfm then ur just plain dumb lol
byron
Forum Admin

Joined: 07 Mar 2004
Posts: 160
Location: Newark, DE, USA
Reply with quote
Well I must be dumb then, Shocked, just kidding (I hope, lol) , we use it on a site that purely runs scheduled tasks, and does not really require any state management.

This is an extreme example, but, imagine a site that gets several thousand unquie visitors a day going to portions of your site that are dynamic in content, but not really needing state management. Then let's say only 5% of them make it to portions of your site where state management is necessary, ie a shopping cart. So why the additional overhead.

Yes it is good practice to use it, and you do miss out on some functionality, but I would not classify it as necessary.

Not busting your chops Smile, I just think it's good to point out all the pro's and con's, especially when it comes to newbies. Too often with new CF'ers they are interested more in functionality then scalibility. But even with that point in mind, the overhead is minimal, but could actually make a difference in an extreme case.
loftboy
Forum Regular

Joined: 24 Jun 2004
Posts: 1129
Location: Colorado
Reply with quote
well it doesnt create that much overhead, actually it will run faster with it then without it. Think about it? if its there and gets paresed and continues, if not then it searches every directory for it, so which takes more overhead?

state management isnt all it does, even like in your case there really isnt a reason not to use it. (for good practice)
lets see not only puttting the db variables, so in case it changes, u just change it once there instead of doing it on every page with a db call.
global error handling, makes more sense too do it once in the application file then on each page.
global variables, such as link fixes to make using includes much easier or paths to folders or pics.
cfc objects calls to drastically reduce to overhead on indiviual pages invoking components.
headers, footers, etcs

and how about favicaon links, cache-controls, users on-line scripts, counters, setting no spam email variables

id say that not using it doesnt have u loose "some" functionality, id say that u lose a **** load of functionality. And for a newbie not learning to use it or onRequestEnd.cfm isnt good practice or very smart.
while sure it will still run but I cant think of one decent developer who wouldnt use it no matter what.

not trying to knock on u either but by not using it ur just creating a crap load more work for yourself.

now on your example, well thats not a valid argument at all. If u have that many visitors then its crucial to be able to run code in the application file to reduce the overhead, after all thats whats its meant for. It all goes back to portability and reusable code.

u know what i mean vern.

lots of pros & really no cons, since i dont think u could really point out any example that wouldnt benefit from it, even an extreme example.
not to mention saving a lot of your tech time trying to fix a newbies site cause they never learned to use the file and now they cant figure out how to login, lol, i cant even count how many times i have answered that ?.
i could go on and on but i have a breeze meeting with MM now, so gots to go.
application.cfm
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic