Jump to content
Larry Ullman's Book Forums

Menu Generation - Saving Mysql Resources


Recommended Posts

Hi Larry (and crew!),

 

While I didn't see you discuss this specifically in the Advanced book, it is an advanced topic, so I figure this is the best forum for it:

 

 

I am working on a CMS for my company. The navigation menu is generated based on database queries, ie, the menu changes depending on upcoming events and happenings and also depending on the privileges of the logged in user. The queries to make the menu are a little involved, and it seems like a real waste to re-run those queries and regenerate the menu on every single dingle page load.

 

Instead, I would like to run the queries just once upon each user login, and store the generated menu somehow so we can reuse it on every page load.

 

My question is, what is the least server intensive way of doing this? To store the generated menu in a multidimensional $_SESSION['menu'] array? Is there a standard solution that advanced programmers use when they don't want to re-run the same MySQL queries constantly?

 

 

Many thanks,

David

Link to comment
Share on other sites

Good question. The idea of caching the output of the dynamic menu generation is a very good one. But what you're talking about isn't user specific, so it shouldn't go in a session. The easiest solution would be to have PHP write a text file of the menu's HTML. Then the CMS just includes that text file in the right place. A script on the admin side could update the text file whenever something on the admin side happens that would change the menu's options.

Link to comment
Share on other sites

 Share

×
×
  • Create New...