Forum Moderators: coopster
My question is rather than query the database to display the page each time, is it more efficient to read the links data from an included text file? ...don't know if that is faster/slower. I could pull the data from mysql to create the file when it needs to be updated.
Elsewhere on the site, mysql queries will be used a great deal. In a best case scenario, the site will receive 5000 hits /mo. (I doubt the links page will see much usage). I'm sure mysql can handle that load but ...I'd like to practice "best known methods".
any opinions are appreciated.
I'd suggest making the SQL database the one definitive source for your website data.
If you want to keep load on your SQL server down for semi-static data, you can write a little script that creates static web pages out of your MySQL data, and run it as needed (maybe scheduling it to run periodically).
...you can write a little script that creates static web pages out of your MySQL data ..
Thanks for the suggestion. Haven't created static pages (via database) before. I'm guessing it goes something like...
open file (links_page.html)
write header stuff
pull data from mysql, format data into HTML links, write data
write footer stuff
close file
or perhaps,
Just create a pre-formated HTML page and insert [link_info] [/link_info] that encloses the links. Then parse the file when link info changes.
Then either make the PHP page automated on a cron job or run whenever the admin adds information to the db.
In addition to other benefits of a templating engine, smarty caches data (and caching can be controlled). So, if I have a list of links in the database that do not change very often, the output of the query can be cached. And, when a change is made ...say a link is added, the script can re-generate the cache.