Navigate
Home
ArticleWiki
Forum
Newsletter
Links
Tech News
Welcome Guest.
Username:

Password:

Remember me

What impact does file extenstion have on a website
Welcome, Guest. Please login or register.
February 07, 2012, 06:11:45 AM
11513 Posts in 1262 Topics by 496 Members
Latest Member: Beerdernill
Experts Round Table Network  |  Web Technologies  |  General Web Dev  |  What impact does file extenstion have on a website « previous next »
Pages: [1]
Author Topic: What impact does file extenstion have on a website  (Read 1113 times)
thepreacher

Offline Offline

Posts: 79


« on: June 19, 2007, 12:28:42 AM »

I only use PHP for my server side scripting then the rest is just html and javascript. I tend to mostly use .php for all my files. I was wondering if it matters whether the extention is .php OR .html. What impact if any does it have on anything. Is there a best practice for using extensions if so what is it?

And Oh while you're at it, there are some websites like this one where the current loaded file name is not displayed in the address bar, like right now I cannot tell the name of the file that displays this page on the system, the address bar only displays the folder. How do I do that?

Cheers.
Logged
GrandSchtroumpf
Mentor

Offline Offline

Posts: 432



« Reply #1 on: June 19, 2007, 12:52:37 AM »

The file extension does not matter.
The only thing that matters is the "Content-Type" (mime type) in the http headers.

For instance, this page uses the following:
Content-Type: text/html; charset=ISO-8859-1


> like right now I cannot tell the name of the file that displays this page on the system

If you use the RSS feed to get to this pages, you'll get this URI:
http://www.expertsrt.net/smf/index.php?topic=1276.msg11235#msg11235
Which probably points to a real file (index.php).

Then, the site uses an URI-rewriting apache module called "mod_rewrite" to build prettier URI aliases.
Like this one:  http://www.expertsrt.net/main/forum/topic,1276.msg11235#new
Logged
rdivilbiss
Moderator
*
Offline Offline

Posts: 424



WWW
« Reply #2 on: June 19, 2007, 07:36:11 AM »

A page which ends with PHP will be parsed by the PHP pre-processor on the server even if it has no php code in the page.

Whether or not that adds any significant time to the page load is probably a concern only to the busiest of sites, but some time is added by having the page parsed by the PHP pre-processor.

Logged

Rod
VGR
Mentor

Offline Offline

Posts: 724



WWW
« Reply #3 on: June 20, 2007, 11:58:49 AM »

the start of the right answer has been written by Rod...

The file extension doesn't matter, but the workload impact on the web server does...

I think you understood that ***in normal circumstances*** (ie, settings ;-), a .htm or .html page is a static page, and a .asp, .jsp, .php, .phtml, .php3, why not .php4 etc ad nauseam are scripts, in fact requiring a "load time", a "start time" for the preprocessor parser, then execution on the system library (= framework = native API = lowest layer of the actual framework = machine code), just to start rendering the real output, ie HTML (in a large sense, be it XHTML, DHTML, pure HTML 2.0, XML data, TXT (ascii text)... whatever)

In fact, the mime type returned has no influence on the "overall execution time".
Even a .html URI can in fact be parsed as a script.
On the contrary, a .php named URI could very well in fact be a static or quasi-static web page.
Both would return a mime type of text/html

Execution time completely depends of ***your choices*** in the webserver's configuration.

There are uses for all kind of combinations, but I will present what I think is the best idea :

1) if you either take over a pure static website (.html extensions everywhere, with some .js perhaps), or don't want to reveal at firts glance the script engine you're using,
2) keep always one extension for all your files : .html
3) add the AddType and IndexPage stuff required in Apache's httpd.conf so that .html pages are parsed by default
4) you can begin to add small PHP tagged parts in your static pages - or write perfectly normal pure PHP scripts except for the extension
5) you can even avoid the "overhead" time of opening pure HTML pages for parsing by using .htm (and not .html) for them ;-) so in this case you've the best of the two worlds : you protect your scripting skills against evidence at first glance and thus avoid the rawest attacks, and you've a consistency in your web pages' names and can do (script, no script, parsed, not parsed, etc) as you wish inside of them.

regards
Logged

techie overlord, answers all kind of questions on http://www.europeanexperts.org
Pages: [1]
« previous next »
    Jump to: