Parse HTML as PHP

The more files the server determines it needs to pass through the PHP interpreter, the more overhead involved, but I think this goes without saying. If your site does not have ANY pages with plain HTML, then you’re already paying all the performance penalties that you could possibly pay – adding HTML to the list is no different in this case than simply renaming all the files to have a .php extension.

The real performance penalty would come if you do have plain HTML pages – the server will needlessly pass these pages to PHP for interpretation when none is necessary. But even then, it isn’t dramatic – the PHP interpreter won’t be needed for those HTML pages, so it won’t do anything aside from determining that it doesn’t need to do anything. This has a cost, but it isn’t significant.

Now, if we’re talking high-volume here, every little bit of performance matters and this would not be a practicable solution. For low- to mid-volume sites, however, the performance penalty would be nill.

If this is a one-time change and there are a limited number of files that are affected, then it may be more conservative to use a FilesMatch directive.

<FilesMatch "^(file_one|file_two|file_three)\.html$">
  AddType application/x-httpd-php .html
</FilesMatch>

Leave a Comment