Welcome Guest, Not a member yet? Register   Sign In
how to properly cache menus and other parts of a web page
#1

[eluser]AtlantixMedia[/eluser]
Hello,

this is my current way of handling menus and rarely changing parts of a web page

1) I store all the menu items in a db (name, url code, access level, visibility, etc)
2) from the admin panel, I run a function which saves relevant data (name, url, acces level) to a $config['menu'] array file
3) the file is then autoloaded
4) array is accessed in the different views to build these menus on the fly

Now, one simple way would be to simply save the final html and load that. problem is, there are some menu items which can only be seen by the admin. others can only be seen by a moderator. all the other have regular guest/registered member access.

what would be the proper way to approach this? I'm looking for a final approach which I will be using till the rest of my life Smile

thanks in advance
#2

[eluser]tonanbarbarian[/eluser]
i dont know if there is a "proper" way to do this
one suggestion though would be to use sessions.
When the person first comes to the site either build the menu, or at the least grab all of the menu data and store it in the session.
If their login status changes i.e. they login or logout, you recalculate.
this way you only rebuild the menu when you need to for each user
#3

[eluser]AtlantixMedia[/eluser]
thanks for the info. that is surely one way to do it. any other perspectives?
#4

[eluser]Crimp[/eluser]
Related to menus and navigation: use URI.
Related to specific user: use session.




Theme © iAndrew 2016 - Forum software by © MyBB