Technology in terms you understand. Sign up for the Confident Computing newsletter for weekly solutions to make your life easier. Click here and get The Ask Leo! Guide to Staying Safe on the Internet — FREE Edition as my thank you for subscribing!

Why do my “.cfm” files work in some browsers and not others?

Question: I have a few pages on my web server that have been created using Cold Fusion, and thus have the “.cfm” file extension. When I view those pages in my browser, they seem to work just fine. However I’ve been getting reports of some people seeing raw HTML when the view those pages, and not the formatted pages I’d expect. What’s up with that?

Well, the good news is that’s it’s most likely an easy, if obscure, fix that you, or your webmaster, needs to do.

The “bad” news, if you want to call it that, is this: the browsers that are showing you what you expect? They’re technically wrong.

Become a Patron of Ask Leo! and go ad-free!

What most people don’t realize is that the filename extension, the “.html”, “.htm”, “.cfm”, “.php” and so on, is pretty much ignored by your browser. Sure, it’s part of the filename, and it gets sent off to the web server when you view a web page, but that’s really about it.

Your browser really doesn’t care or pay much attention to what the extension is. †

The web server on the other hand, cares deeply.

The filename extension is used by the web server to know how to process the request. By default, “.html” files, for example, are simply copied back down to your browser, pretty much as is. “.shtml” files are pre-processed, and then the results copied down. “.cfm” files are run through the Cold Fusion processor, and the output is sent to your browser. “.php” files are run through the PHP interpreter, and the output is sent to your browser.

But that’s only part of the story. When the server sends something down to your browser, it also includes information that tells the browser what it is it’s sending. For example your “.cfm” file may fire up the Cold Fusion processor, but the results that get sent back down to your browser is just plain old HTML. That makes it easy on your browser, because regardless what wonderful technology was used on the server – Cold Fusion, PHP, or something we haven’t thought of yet – the server just tells the browser “this is HTML”, and the browser knows what to do with it.

The problem arises with unknown file types. If you have on your server a file called “example.leo”, and you request it in your browser … well, the browser doesn’t care that it’s a “.leo” file, it just asks the server for it. The server, on the other hand, has no idea what a “.leo” file is, so it makes an assumption: this must be plain text. And that’s what it tells the browser: “this is plain text”. The browser should just display the contents of the file, without formatting, much like if you had opened the file locally in notepad.

Now, in your case, it looks like your server knows what to do with “.cfm” file requests: send them off to the Cold Fusion processor. But it looks like it has not been configured to know that the output of Cold Fusion is HTML (or alternately, Cold Fusion has not been configured to indicate that its output is HTML). Your “.cfm” pages are probably coming out with the indication that they are text, not HTML. (For the more technically inclined, the HTTP headers returned include “Content-Type: text/plain” instead of “Content-Type: text/html”.)

But wait! It gets more confusing!

Several browsers, I assume to be “more helpful”, will attempt to display pages marked as plain text as HTML anyway. (Presumably if it “looks like” HTML to them.) So this means that even though your “.cfm” pages are incorrectly indicating that their output is plain text, some browsers will incorrectly treat it as HTML.

Two wrongs making a right, as it were.

Other browsers that actually pay attention to the content type, display the output as plain text, which means displaying the raw HTML to their users.

So that was a very long explanation that boils down to this: the server hosting your site is not configured to correctly indicate that “.cfm” output is HTML. Exactly how to correct that will vary based on the type of server you’re running, and may possibly involve settings within Cold Fusion itself.

† – ok, some browsers may pay attention to the filename extension as a hint for what to do with the file. But technically, they’re probably not supposed to.

Do this

Subscribe to Confident Computing! Less frustration and more confidence, solutions, answers, and tips in your inbox every week.

I'll see you there!

10 comments on “Why do my “.cfm” files work in some browsers and not others?”

  1. Hi,

    When I browse to a site which has .cfm files they are not being displayed as HTML but this is only happening on one particular PC, the others that we use are able to display the pages correctly, or rather as we would expect to see them. Is there anything that I can do on the local PC to correct this?

    They were displaying as HTML before, but are no longer on this specific PC.

    Any help would be appreciated.

    Thanks
    Susan

    Reply
  2. I am having hte same problem as susan, when I click on a cfm link I get a prompt to save or open; saving saves the file and open does nothing.

    Reply
  3. My computer just started being weird two days ago. I deleted cookies and temp files from my internet explorer settings, and now i cant see these CFM files. Help?

    Reply
  4. I have read the article. It explains what may cause the problem, but does not offer a solution. I cannot view CFM pages. Same problem as Susan, GDF and Holly. Please help.

    Reply
  5. Reread the last paragraph of the article. It’s not something YOU can correct, UNLESS you are the owner of the server you’re try to access.

    Reply
  6. I am confused. I access a doc system at work fine from my pc as do others from their mobile devices. However, I just got a smart phone and when I attempt to access a .pdf, say, I get a message stating that “this device does not support this type of file” and asking if I want to save this “.cfm” (not .pdf) file to my memory card. You seem to be saying that the problem is on the webserver side, however, I can view and download the .pdf, .doc, .xls, etc… with other browsers from other machines. There would seem to be some sort of difference between browsers/user/viewer configurations as opposed to the webserver/page itself. I accept that how the page is constucted creates this problem (note that I have to trouble downloading .pdf files from the irs website) however, it is also clear that other devices/browsers have no trouble getting the correct files.

    Reply
  7. There is nothing you can do on your end as Leo mentioned. RR is updating their main page as of
    5/22/08 and they are aware of this. CFM files are once again.,…..ON THE SERVER. Not a problem with your computer.

    Reply
  8. I just had to reload windows, and had not reinstalled Adobe reader and I had a problem reading the .cfm files. After I installed Reader – it worked fine.

    Reply
  9. For those who may stumble across this in the search to get a .CFM file to open in their browser.
    Although my browser(s, Firefox and IE) could “see” the file once I added the file type to my PC (XP) neither could actually successfully open things until I installed Adobe Reader. Thanks Joe for your comment, got me up and running.

    Reply

Leave a reply:

Before commenting please:

  • Read the article.
  • Comment on the article.
  • No personal information.
  • No spam.

Comments violating those rules will be removed. Comments that don't add value will be removed, including off-topic or content-free comments, or comments that look even a little bit like spam. All comments containing links and certain keywords will be moderated before publication.

I want comments to be valuable for everyone, including those who come later and take the time to read.