Archived

This topic is now archived and is closed to further replies.

Designing a page caching system in PHP

This topic is 5048 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
* 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 ]]
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)

Share this post


Link to post
Share on other sites