If your options don't change much but still you want to do them dynamic you could try something like this:
Im not sure this is even going to work but i just thought of it. and hope it works 🙂
function createSelect($file)
{
// this looks for the file
if(file_exists($file))
{
$time = filemtime($file);
$time_now= mktime();
$dif=(($time_now- $time)/86400);
// this check how old it is
if($dif<1)//less than one day old
{
include($file);
}else
{
regSelect($file);
}
}else
{
regSelect($file);
}
}
then you need a regSelect function:
function regSelect($this)
{
if($this!="")
{
if($this=='select_1.txt')
{
$sql="select id, name from table_1 order by name";
}else
if($this=='select_2.txt')
{
$sql="select id, name from table_2 order by name";
}
$result = mysql(database,$sql);
while($row=mysql_fetch_row($result))
{
$select.='<option value="'.$row[0].'">'.$row[1].'</option>';
}
// what this does is generate a txt file that contains all the options
// of the select and names it as select_1.txt or select_2.txt
$file=fopen($this,"w+");
fputs($file,$select);
fpassthru($file);
}else
{
echo "No select to generate !!";
}
}
How you use this should be something like this:
<select name="countries">
<? createSelect("select_1.txt"); ?>
</select>
Then if the file select_1.txt already exists and it is quite new then the server will just bring the txt file fast
and if it wasn't already created or is quite old it will regenerate it and use it.
Im not sure if the response is going to be faster in this select example but you could use the same kind of thing and try to cache heavy pages.
Guillermo