Designing a page caching system in PHP

Started by
3 comments, last by neurokaotix 20 years, 1 month ago
I''m attempting to design a good page caching system in PHP and I have a couple questions to ask, I hope that I can get a good discussion on the topic started so that I can get some good design tips. First, the way my system works (as per a tutorial I read on the subject) is it will MD5 the URI of the page and use that as the cache filename. It will then buffer the page output and save it to the cache directory. Upon reload, it will check to see if the MD5 filename for the page exists and if it does it will load the preprocessed page. Problems so far: · It doesn''t know if the page html has been updated · It really doesnt know if say, MySQL data has been updated Does anyone have any ideas on how this can be done? Perhaps someone has designed their own system before and has some tips for me? codekid88: "hail c++ , hail god!!!" MindEngine Development http://medev.sourceforge.net
Advertisement
* I would attempt to solve your first problem by simply adding a cache time-out, like any caching system does. Whereby if a cache hit occurs, the timestamp is checked, and if it falls out of the specified age(x number of minutes), the cache entry is deleted both from the cache directory and the database table containing the cache entries. The new cache entry is then created, and the content served.

* There isn''t any obviously elegant way the system can tell if cache content is old, so you would probably want to store a list of files(in a database table) which should not be cached(that is, their content changes too frequently, or it is user specific) along with the expiry system so that pages served aren''t ages old, or keep getting thrown into the cache and overwritten, which just wastes time

[[ Pancake Meat ]]
Thank you for the reply, it has helped

codekid88: "hail c++ , hail god!!!"

MindEngine Development
http://medev.sourceforge.net
Also, to add to the mix, pages which hardly ever change shouldnt be processed by php until they are updated, be it automagicaly or by you pushing a button to write out a new set of pages

imo, too many people have ''dynamicaly generated'' pages with content that changes once a week or once a day at most, these would be much better served by being static and generated via a script when updates accure (this lets you have your database stored blog and all the fun you get with it AND takes some load of the server)
Or the one pages who content changes every second due to a thingy that says : this page was generated in : X.XXXXX seconds.

[edited by - DevLiquidKnight on February 21, 2004 11:25:54 PM]

This topic is closed to new replies.

Advertisement