3

I've got a website on a shared hosting and I'm using PHP to generate the pages.

As of now, using the management system the admin can modify the database, which is stored in an XML file (SQL is not available). The pages that need to display the content of the database take a look at the content every time they are opened, and the script in PHP generates the appropriate page. It's fast for me to code and it's easy for the admin to maintain.

I'm making my first steps in web-oriented programming and today I thought of another idea: what if the management system updates the database AND generates the pages as HTML pages so that the server doesn't have to execute a script every time a page is requested? Isn't it strictly better in terms of performance? A lot of work a single time instead of a bit of work every time.

tshepang
  • 12,111
  • 21
  • 91
  • 136
user989955
  • 41
  • 3

2 Answers2

1

Yes, static HTML is much x3 (could be more than three time) faster

  • as it does not trigger an additional PHP process,
  • does not require database, no more doggy SQL (which you about to going to)
  • you can discard apache, switch to nginx (who is solid in term of serving static HTML)

There will be more work to ensure your application publish the latest content into static HTML when there is an update, such as pagination (all the sequence is changed)

In general static page is faster, but less flexibility.
Much depend on your site requirements

If you site is less write (look like you are), one more reason to go for static pages.

ajreal
  • 46,720
  • 11
  • 89
  • 119
  • also it might be nice to have some caching layer with APC or Memcache – Narcis Radu Dec 05 '11 at 15:37
  • once you are in static html, apc or memcache is no longer required – ajreal Dec 05 '11 at 15:38
  • no required but very nice to have: PHP performing faster, http://wiki.nginx.org/HttpMemcachedModule and nginX will also perform faster. But I'm sure is not the case in some shared hosting environment. – Narcis Radu Dec 05 '11 at 15:47
0

Short answer, yes, that would work better.

Long answer is get hosting with a SQL database so you can store page content in there rather than generate files each time.

psx
  • 4,040
  • 6
  • 30
  • 59