[thelist] Caching: PHP or Clientside

Mr. Tenuta dtportnoy at videotron.ca
Thu Sep 23 11:42:48 CDT 2004

Thanks for the ideas, I'll cancel out clientside since it is guaranteed larger than 4KB.
Let me explain my problem more in detail.

I have a big DHTML menu with a category/subcategory/link hierarchy. This menu has all its contents in a database (so that adding, removing, editing links can be done in an admin panel). 

The obvious problem is that this menu grabs from the DB each page hit. Right now user level is low so the speed is fine, but I know this will be a huge problem once the site is launched. 

The menu has different states depending on the user session, so it is somewhat personal. I think I've narrowed this down to two possible solutions, although I'm sure there are more.

No matter what, the menu will be sent to a php variable. All the output being caught by PHP's ob functions. The menu changes depending whether the user is logged in or out, and if the user's logged in, special categories will show up if the user is staff, or an admin.

Option 1 by session: I store the output cache into a session variable. If a menu state(log out or log in) occurs, it'll grab from sql again then overwrite the current cache until another menu change occurs. If i do this i need to know if session variables can store around 10kb of data? Since its dynamic per session, i have to emphasize that this will be a heavy traffic site.

Option 2 globally on db: My db connection is open every page since its a heavy db site.(not sure if that makes a difference in anything)
I create fields in a new table for every menu state.Let's say logged_out, user_logged, staff_logged, admin_logged. Then i create datetime fields to store the last time any of the states were updated.

Every page load it'll connect to this table and compare the current menu state date with the last updated date. I'll have a constant, setting how often I should update cache(lets say every 12 hours). When dates are compared, if 12 hours passed, get menu contents from SQL and update cache, else just read from cache. 

Which would be most efficient in this case? Or are there more obvious solutions that I'm overlooking?

Thanks for the help :)

Lawrence Tenuta @ neoDesignz

More information about the thelist mailing list