View Full Version : Any way to create .html file from a .php file with php command?

12-21-2006, 04:03 AM
Suppose I have a php file, index.php that contains scripts that accessed mysql database and produce a nice looking webpage.

In order to reduce the load of Mysql query, I would love to have my index.php converted into a static index.html file for every half hour so that browser can be set to view just the index.html.

Can anyone help me for any trick or way to be able to convert this php into html file through a php script? Note that I do not have shell access to perform wget/GET command.

Thanks in advance for your help.


12-21-2006, 04:25 AM

...that just creates the file though, to do it automatically every 1/2 hour would normally require a cron job (which would use wget or php itself)

if you do not have cron available then anything else is a hack.. but you could have a hidden iframe in your index.html that called say rebuild.php, rebuild.php would check the database or a textfile for the last time the file was rebuilt, and if the time was up would use the above script.... such scipts are best avoided though if you have cron available.

12-21-2006, 01:15 PM
You could always try caching the site in apache, so it will not process the page on every request

<FilesMatch "\.(php)$">
Header set Cache-Control "max-age=2592000"

<FilesMatch "\.(php)$">
Header set Cache-Control "max-age=604800"

<FilesMatch "\.(php)$">
Header set Cache-Control "max-age=43200"