An Architect's View

CFML, Clojure, Software Design, Frameworks and more...

An Architect's View

SES - Bah Humbug!

September 22, 2005 · 30 Comments

I've always maintained a healthy skepticism about the effectiveness of so-called Search Engine Safe URLs but after a yet another question about how to do SES URLs with framework X, I decided to go ahead and convert my blog (and entire website) to use SES URLs just for kicks. The code is trivial. My various Application.cfm files simply include /ses.cfm at the top and, for the most part, I simply changed how the myself variable is set in the various fusebox.init.cfm files:
<cfset self = "/index.cfm" />
<cfset selfAction = self & "/" & application.fusebox.fuseactionVariable & "/" />
The /ses.cfm just contains this code:
<cfset isArg = true />
<cfloop list="#CGI.PATH_INFO#" index="av" delimiters="/=&">
   <cfif isArg>
      <cfset argName = av />
   <cfelse>
      <cfset URL[argName] = av />
   </cfif>
   <cfset isArg = not isArg />
</cfloop>
Using /=& for delimiters just means that any leftover &arg=value pairs in the URL will be correctly handled. Then I went through my display fuses fixing most (all?) of the old &arg=value URLs. A minor gotcha: relative file paths don't always work (hence /index.cfm) so I had to fix a few image references etc. Let me know if you find any broken links as a result of this change.

Tags: coldfusion

30 responses so far ↓

  • 1 Geoff Bowers // Sep 22, 2005 at 5:09 PM

    I think the reality is that SES are really just humbug these days. Parameterised queries are indexed by the search engines that matter. But what is important are Friendly URLs; I'd define these as URLs that are human readable and memorable. But more importantly, keywords in your URL rank very highly in most search engine algorythms.
  • 2 Raymond Camden // Sep 22, 2005 at 7:19 PM

    Someone pinged me noting that his relative URLs didn't work under BlogCFC's SES format. I never ran into the bug because it was my impression that relative URLs weren't valid when included in your RSS feed. Therefore I always use full URLs for my links in my entries - just out of habit.
  • 3 Yacoubean // Sep 23, 2005 at 7:36 AM

    Not to start another 'To Framework, or not to Framework...' war, but this is one of the main reasons I haven't been converted to the frameworks crowd yet. You have to write a .cfm file that converts the output of your framework code, so its more human/SE friendly? I would have just made my application behave that way in the first place. But what do I know, I'm just a lowly &quot;CF is easy yet powerful&quot; guy. ;)
  • 4 Raymond Camden // Sep 23, 2005 at 7:41 AM

    Yaco - I'm using Model-Glue for my rewrite of cflib.org. I used SES by simply adding ISAPIRewrite. It is free for one domain and was very simple to use. I can test locally using Apache and (pretty much) the same regex rules. MG has no idea I'm using SES URLs.
  • 5 Yacoubean // Sep 23, 2005 at 7:47 AM

    Ray,

    Ok, so you didn't write a .cfm to clean up the MG output, you wrote a webserver extension (or what ever you'd call it). That's very smart, and I'm impressed. But, I still don't like that people have to hack their frameworks to get them to put out clean code. Isn't the idea behind frameworks to make it easy for you to write good, clean, OO code? Then why do the frameworks create 'dirty' code?
  • 6 Raymond Camden // Sep 23, 2005 at 8:01 AM

    Why do you call it a hack though? I didn't have to do anything to the framework. I just used the third party tool along with it. I'm not so smart btw, ISAPIRewrite was written by someone else. If you think about it, this is a great solution. Let's say my SES rules change. I can update my links and not worry about the framework at all. It will work as is.
  • 7 Yacoubean // Sep 23, 2005 at 8:10 AM

    What is a hack? Its modifying something to fit your needs, as far as I understand things. Your solution is GREAT, and I congratulate you for thinking of it. However, since I don't use frameworks, I don't need to hack my code's output. It just works the way it should. Coincidentally, I just saw this on a mailing list: &quot;Working on my first Fusebox app so anything to help me close those )@#$*#*$ trailing slashing in the circuit files will be a big help!&quot; I don't have clue what he's talking about, because I don't use FB. But this looks like more evidence of dirty code from a framework.
  • 8 Raymond Camden // Sep 23, 2005 at 8:14 AM

    I guess we will have to agree to disagree. To me, I didn't hack MG. I didn't do _anything_ to MG. All I did was change how I write my own links. It is a hack - but not in the MG area. I would/could use the same hack for my old, non-MG site as well.
  • 9 Yacoubean // Sep 23, 2005 at 8:18 AM

    Yes, you didn't hack MG. You are hacking MG's output (the URLs), unless I am totally misunderstaning your situation.
  • 10 Raymond Camden // Sep 23, 2005 at 8:20 AM

    MG doesn't have an output like that though. It does have a URL format. The developer is responsible for writing the links correctly. I did that. But I did it in a way where I use SES URLs and ISAPIRewrite fixes it. Basically a two step process. I did _not_ modify anything in the MG files. To me, this means it wasn't a MG hack, or even a hack at all. But again though, we are probably going in circles. Sorry Sean. :)
  • 11 Yacoubean // Sep 23, 2005 at 8:24 AM

    Oh, I get it. &lt;extends a freindly hand shake with a smile&gt;
  • 12 Sean Corfield // Sep 23, 2005 at 10:24 AM

    Yacoubean, what's your beef? No one is modifying the framework, no one is modifying the output. My post made it pretty clear I thought that I changed my Application.cfm and a few of my display files and that's it. In other words it's trivial to become &quot;SES&quot; and it's completely independent of any framework.

    Now, as it happens, Model-Glue 1.0 (coming soon) has an extension point that allows SES to be coded &quot;into&quot; the framework. I recently posted to the Model-Glue mailing list how to do that. Again, no change to the framework at all - a great bit of design on Joe Rinehart's part to be able to offer such a seamless extension point!
  • 13 Yacoubean // Sep 23, 2005 at 10:35 AM

    My beef is that Frameworks appear to produce dirty code. See my 11:10 am comment.

    But, I have been soundly spanked by you and Ray, and I'm happy to go back to my corner. ;)

    Actually, I have almost been convinced to learn a framwork and apply it to my future applications. The reason? Frameworks appear to provide a standard for good coding practices. I said 'appear' because there are countless frameworks out there, and everybody seems to have their own hacked version of the framework (I am not point at you, nor Ray).

    If the frameworks would keep a stable core that almost never changes, and all of the coders would refrain from hacking the core (which is something I've heard you stress, Sean), then they would be great.

    I'd be even happier if Helms, Dealy, Rinehart, and all of the others out there would get together and make a true standard CF framework. Now that would be something to party about!
  • 14 Sean Corfield // Sep 23, 2005 at 11:56 AM

    Once again you are making uninformed comments, Yacoubean. The comment about closing slashes in the circuit file is a plea for an XML editor to assist with writing the XML configuration files - nothing to do with code production.

    Now, as it happens, Fusebox compiles that XML to CFML code that is typical of compiler-generated code. The parsed/ directory should be considered &quot;magic&quot; and never examined since it contains machine-generated code that would never pass anyone's test of best practices. That has nothing do with *using* the framework, however.

    Anyone who is using a &quot;hacked version&quot; of a framework is not using a framework, IMO.

    There cannot be a single &quot;true standard&quot; framework because there are different applications out there that have different needs. Hence, different frameworks suit different applications.

    If you ever come to one of my frameworks talks, you'll hear me talk about different situations where you might choose Fusebox, Model-Glue or Mach II depending on your needs. You'll also hear me talk about the pros and cons of each framework.
  • 15 Yacoubean // Sep 23, 2005 at 12:37 PM

    I admit my comments are uninformed. I am not a frameworks user (although I am an experienced CF coder). I read his email, and he said he needed help with his first FB app, and I made an incorrect assumption, apparently.

    &quot;The parsed/ directory should be considered 'magic' and never examined since it contains machine-generated code that would never pass anyone's test of best practices.&quot;

    That comment kind of bothers me, but I know why you made it. It is a desire to keep and maintain a standard. If I go look at the generated code, I might be tempted to hack the framework, which would break the standard (which is bad).
  • 16 Sean Corfield // Sep 23, 2005 at 12:56 PM

    Yacoubean, yup, that's exactly why I made that comment. Machine-generated code is usually pretty dreadful although many times no one actually sees it at all because it's immediately translated to some non-human readable form (Fusebox could probably be made to compile these direct to Java bytecode when running on CFMX although that would be unsupported machinery :)

    A lot of people have misconceptions about Fusebox - and frameworks in general. I was a vociferous opponent of Fusebox back in the day but now I'm a strong advocate, as I am for Model-Glue and Mach II.
  • 17 Yacoubean // Sep 23, 2005 at 1:02 PM

    When I really am honest with with myself, I have to admit that I just don't like the idea of disciplining myself by using a framework. CF is extremely flexible and agile, and Frameworks seem so structured and rigid (correct me if I'm wrong). It is /very/ possible to write good OO code, using good practices, without using a framework (which is exactly the point that Simon Horwith likes to make). But I have come to see that there is a LOT of value in the frameworks.

    I also have to admit that a big reason I don't want to learn a framework is just that. I don't want to learn a framework. I'm lazy. :)
  • 18 Sean Corfield // Sep 25, 2005 at 11:56 PM

    Well, it's true that a framework places some constraints on you but the trade off is that in return for &quot;suffering&quot; those constraints, you get the value of the framework doing housekeeping stuff for you. For some people, that's a good trade off - for others, it isn't.

    I rarely find the constraints bothersome - but I've programmed with some very rigid frameworks in the past. Fusebox et al are very lightweight by comparison...
  • 19 Sean Kozey // Sep 26, 2005 at 12:34 PM

    Hey Raymond,

    Have you tested ISAPIRewrite on a site under relatively heavy load? I'm curious as to what the overhead of having the filter run on every request would be.

    For the sake of (very) loosely defining what I mean by &quot;heavy&quot;, say over 100,000 page requests a day, where most of the page requests are being processed through the application server and involve executing some server-side scripting.
  • 20 Raymond Camden // Sep 26, 2005 at 12:49 PM

    CFLib gets.... maybe 5k hits per day I think. Which isn't light, but not 100k per day. CFLib will be using SES whenever I wrap it up, which may be EOY. So I don't have any hard data now. :( The only site I had that got 100k per day was DeathClock, which I sold a few years back. Believe it or not, I actually had that running on _Access_. Of course, I heavily cached.
  • 21 Sean Corfield // Sep 26, 2005 at 5:53 PM

    I can't comment on the IIS URL rewriter but macromedia.com - very high traffic - passes all requests through Apache's rewrite engine with I think about 1,000 rewrite rules, many involving regular expressions, and there's no significant performance hit from that...
  • 22 Nando // Sep 26, 2005 at 7:34 PM

    Following up on Geoff's comment - i found enough indications in my research on this topic that search engines *might* not follow urls that seem to be positioned so deep in the file structure - unless they are linked to from outside the site, that i decided against using an SES system in favor of a friendly url approach.

    Although Spike's friendly url system seemed perfect at first, that's the one FarCry uses i think, what i wound up with is a system that writes static .cfml files to the root of the site with the dynamic url specified within it like the following:

    getPageContext().include(&quot;index.cfm?view=24.12&amp;lan=en&quot;);

    The faux static .cfml page is named according to the page settings a user specifies, and the site navigation adjusts itself accordingly.

    Not trivial, to be sure, but it's self-contained - it'll function even when we don't have access to settings on the server. And most importantly, we can specify a url that can go into a print advert. And that *may* help search engine placement by handing a keyword to the bot in the url.
  • 23 Sean Corfield // Sep 26, 2005 at 9:40 PM

    I also have friendly URLs for some things on my site - done with Apache rewrites - such as /resume and the /search/keyword stuff.
  • 24 Mike // Nov 24, 2005 at 9:57 AM

    Yakoubean, if I understand the underlying concern you had: in many frameworks you use index.cfm as a hub, with querystring information appended to the url to allow the engine to figure out what function is being requested. In that sense I can see your point: &quot;mysite.com/index.cfm/go/blog.entry&quot; could be construed as &quot;dirtier&quot; than &quot;mysite.com/blog/entry.cfm&quot;.

    It's a small price to pay IMO when you get the benefits of a framework. I have a largish site using FB4, and it's doing very well in the search engines with SES. One benefit that SES has over a physical file, is you can inject keywords into linking URLs for SEO.

    eg:
    &quot;corfield.org/index.cfm/ColdFusion/Guru/go/do.something/&quot;

    :)
  • 25 Clint // Jan 20, 2006 at 3:18 PM

    For some reason or another I keep getting index.cfm/method/ added to the URL each time I click a link (eg. URL/index.cfm/method/index.cfm/method/main.welcome and so on). It looks ugly but works until I leave the circuit. Then when I go to a page outside the circuit I'm currently in it throws and error because of it. Other than that the script seems to work great! Can you think of any reason that might happen? I'm using FB4.1 on a CFMX7 server.
  • 26 Sean Corfield // Jan 20, 2006 at 4:01 PM

    Clint, you can't use relative links with this technique - you must use /index.cfm, not index.cfm - because the browser thinks the SES URL is the actual path and just appends the relative link.
  • 27 Clint // Jan 24, 2006 at 12:17 PM

    That was it! Thank you. Now I just have to go back and replace all of the old links, what a drag. I never realized it was this easy to generate SES URLs. If I would have planned this in the first place... Anyway, you've made my job a lot easier. Thank you again for all you do.
  • 28 se // Sep 1, 2006 at 6:51 PM

    how to pass jsessionid with SES?
  • 29 Dave Cahill // May 15, 2008 at 9:37 PM

    Well Sean I think my issue might qualify as a broken link. Im running a page that uses CFGRID and if I use SES, the grid is not displayed. If I then reload the page with a standard Fuseaction call without SES, the grid runs. All subsequent page loads, with or without SES cause the grid to be displayed, even after reparse. It seems to not load on all initial attempts to run the page with SES. Im running FB4.1 on CF8 with an access database.
  • 30 Chris Bowyer // May 25, 2008 at 4:20 AM

    I'm having exactly the same issue as Dave, but running FB5.5.1 out of the box (so to speak) with the core and skeleton as sub directories of my wwwroot and the following added to my fusebox.xml.cfm parameters:

    &lt;parameter name=&quot;queryStringStart&quot; value=&quot;/&quot; /&gt;
    &lt;parameter name=&quot;queryStringSeparator&quot; value=&quot;/&quot; /&gt;
    &lt;parameter name=&quot;queryStringEqual&quot; value=&quot;/&quot; /&gt;

Leave a Comment

Leave this field empty: