The Dopefly Tech Blog
<< The Dopefly Tech Blog Main page
Front Controller Frameworks Suck
posted under category: ColdFusion on March 2, 2010 at 8:09 am by MrNate
I always hated them for this one reason. How do you explain this URL:
www.example.com/index.cfm?fuseaction=main.default
What I dislike about that is...
- It's hard for your users to remember or even type
- It's ugly to see
- Your web stats say everyone visited one page - index.cfm - they had different query strings, but they only visited one page
- Your SEO is hurt. How does the googlebot know the difference in importance between the fuseaction query param over any other params? Sure, it's smart, it knows, but it can't really know, you know?
- It reduces the number of results in this search
Really, it comes down to your users, their experience, and how they see your application. While it's not as important as your usability, design, content or uptime, it does take away from the overall quality.
So what can be done about this problem? Few have tried, some have succeeded. Here are the strategies that are out there.
- CFM pages everywhere.
This is generally the opposite of using a framework. All of the hassle, none of the benefit.
- URL Rewriting. As requests come to the server with an attractive URI, they are translated into whatever your application needs to load it by.
This is a good strategy, and it works well. On Windows with IIS, most of the software is either expensive or buggy, and definitely not portable. On Apache, mod_rewrite is great. Either way, you cannot make a cross-platform solution, meaning URL rewriting on an open source project is a no-go.
- Generated CFM pages everywhere.
You have software that spits out static files from dynamic actions in your framework, that call back in to your framework. In our example, a /main/default.cfm page would be generated that may set the fuseaction querystring parameter and invokes the framework. This is a great solution, but I've never heard of anyone putting it to practice. Writing this software is deceptively complex.
- The OnMissingTemplate rerouting method.
You link to pages that do not exist, then have an onMissingTemplate handler in your Application.cfc file that redirects requests to your framework with the right parameters. This new URL might look like example.com/main/default.cfm, which doesn't exist, so your onMissingTemplate method fakes like it's the ugly URL and invokes the framework.
Can anyone think of another method of doing it?
Personally, I like the OnMissingTemplate method a lot. The distinct advantage above the URL rewriting method is that this one is portable without installing other software. Of course it doesn't work everywhere, but it almost always will.
In summary, make your users happier and write your next application with a better SES strategy.
Post A Comment!
On Mar 2, 2010 at 9:50 AM Andy Bellenie (andybellenie who dances with gmail.com) said:
I don't see what's difficult about URL rewriting in IIS. Isonic's free ISAPI filter is really good and no more complex than mod_rewrite. We use it over at CFWheels for our IIS based rewriting.
On Mar 2, 2010 at 10:00 AM Raymond Camden (ray at the endearing camdenfamily.com) said:
I'll ditto Andy, although I use IIRF. I develop on Apache and use the same .htaccess rules on IIS. It works perfectly well. Also, Google Analytics has no problem separating index.cfm?event=1 from index.cfm?event=2. It can use the TITLE tag to recognize them as different pages. Any search engine that can't isn't really doing a good job. I mean, shoot, dynamic web pages have been around forever. The idea of "some file name, different query string" isn't exactly new.
On Mar 2, 2010 at 10:12 AM Steve Bryant (steve at the endearing bryantwebconsulting.com) said:
I agree completely. The framework that we use relies more on page controllers than a front controller and doesn't use hub-and-spoke.
The only place I would disagree is that having .cfm files everywhere prevents the use of a framework.
I'm not sure what you can do with hub-and-spoke that can't easily be done without it.
On Mar 2, 2010 at 10:17 AM Nathan Strutz (http://www.dopefly.com/) said:
Andy, I know that the Ionic ISAPI Rewrite on IIS is touchy and has made my servers unstable, one wrong regex blows the whole server. It's fine once it's running, but don't touch it. If you don't see what's difficult about URL rewriting, maybe you are more of a regex master than most of us.
Ray, I haven't used IIRF, and you're right about Google.
In either case, you're developing software that requires a web server plugin to work in different environments, especially IIS. Cross-platform won't really work.
I just like the OnMissingTemplate method, but that's my preference. It's obvious that URL rewriting is the long-standing champion, and it's obvious that most of us don't use it.
On Mar 2, 2010 at 11:06 AM Raymond Camden (ray who can't believe it's not camdenfamily.com) said:
"Cross platform won't really work" - but isn't there always going to be differences between Apache and IIS? Ignore URL Rewriting. Even the _setup_ of a virtual server is different. Unless you are writing an app to be dropped into a subfolder, the setup process will necessarily be different. Therefore having a different URL Rewrite setup doesn't seem like an issue to me (as long as you can use the same rules of course).
I think onMissingTemplate is good as well - although it does still require a .cfm in the url, which ain't so bad of course.
On Mar 2, 2010 at 11:22 AM Brian Swartzfager (bcswartz who can't believe it's not gmail.com) said:
Two things:
--It looks like most of the current ColdFusion frameworks provide a means of generating SES URLs via the framework itself, without having to worry about whether the web server is IIS, Apache, or "other."
--I can see the value in having SES URLs for a publicly-accessible website designed to attract users, but not if you're building intranet or extranet web applications requiring authentication to access.
On Mar 2, 2010 at 1:07 PM spills (spillsmills@microsoft.com or @google.com or @yahoo.com) said:
IIS 7.XX has URL rewriting built in with wizards if you so wish to use. It is even "kinda" Apache MOD Rewrite compatible and I can say the URL rewriting works really well without the overhead of the .dll approach.
On Mar 2, 2010 at 2:14 PM Ben Nadel (ben has underestimated bennadel.com) said:
I use IIS MOD-Rewrite, which has been very fast and very stable. It's pretty cheap ($150/server) and is apparently the most Apache-compatible IIS mod rewrite available. But for me, the selling feature was that it allows for very easy per-site rewriting and had a sweet GUI for installation and management.
On Mar 2, 2010 at 3:41 PM Matt Woodward (http://blog.mattwoodward.com) said:
The "problem" you point out doesn't mean front-controller frameworks suck. It just means if you care about the issues you raise that you have to address them somehow.
Simple solution: use Apache and mod_rewrite on both Windows and Linux. Problem solved. And then if you really want to, throw a servlet filter in the mix and eliminate the index.cfm page from the URL too. Gives you a ton more flexibility and seems way less hackish to me than onMissingTemplate.
On Mar 2, 2010 at 7:07 PM Steve Bryant (steve at the endearing bryantwebconsulting.com) said:
Matt,
I took Nathan's "Front Controller Frameworks Suck" to be friendly hyperbole.
The issues do seem to me to be legitimate challenges - costs if you will. That doesn't mean that the benefits of front controller frameworks don't outweigh the costs. Clearly for many they do.
I am curious about how these challenges are solved on shared hosting. That isn't meant as a dig, but as a legitimate curiosity.
On Mar 2, 2010 at 7:47 PM Tony Garcia (http://objectivebias.com) said:
@Steve,
On shared hosting, I've used the built-in SES URL capabilities of the framework (ColdBox in my case) and ISAPI Rewrite (available in Hostek shared hosting plans) to remove the leading "index.cfm/
I've never had a problem w/implementing "pretty" URLS when using a front controller framework either in CF or in PHP
On Mar 2, 2010 at 8:32 PM Steve Bryant (steve who really likes bryantwebconsulting.com) said:
Tony,
That makes sense. I guess I got confused and thought that you had to do that on the web server.
Come to think of it, however, I should have known better. I used a nice utility like that back when I used Fusebox.
Thanks for the clarification.
On Mar 2, 2010 at 11:15 PM Nathan Strutz (http://www.dopefly.com) said:
Steve has my position pretty right, actually I have always been a framework superfan. The shared hosting, and even minimal hosting where you are just not able or likely to touch the web server itself or install any plugins, is what I generally target in my software - the lowest common denominator - that's what you target when you want your software to run everywhere.
I'm expressing a long time issue I've had and have yet to take up on the blog. Yeah "Frameworks Suck" is overselling myself and the subject :)
I put out some open-sourcey apps and I always take a stance against requiring any server configuration or special setup. That's why I like Derby, per-app mappings, Admin API access, and yes, even rolling my own SES URLs.
On Mar 3, 2010 at 6:51 PM Tim LEach (nicklepedde@example.com who would have preferred an address at gmail.com) said:
I think you missed a middle man. Why not do this:
example.com/index.cfm/SES_page_name/Another_one?Misc=var&page=2
Where the switch and/or part you want to be seen as important to Search Engines comes after the index.cfm, and it's also not hard to remember/read. Plus you don't quite need to do something as dirt as onMissingTempate. That would be the route I'd go.
On Mar 4, 2010 at 8:14 AM Nathan Strutz (http://www.dopefly.com/) said:
Oh Tim, you're right, I completely forgot the .cfm/argument trick. Doesn't that one require a tweak to your web server or something to make it work? I haven't ever tried it. I do sort of dislike that approach just because it still looks like a meessy address. Thanks for bring this one up!
On Mar 5, 2010 at 12:30 PM James Moberg (james, by way of ssmedia.com) said:
When using IIS, only the physical script_name is logged by IIS... so if you use index.cfm/SES_pagename.htm, only "index.cfm" will be logged.
Because of this, we ended up writing our own CFLogging script that records the entire path_info value and not just the script_name.
Post A Comment!