CodeIgniter Forums
how to properly cache menus and other parts of a web page - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: how to properly cache menus and other parts of a web page (/showthread.php?tid=4881)



how to properly cache menus and other parts of a web page - El Forum - 12-21-2007

[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


how to properly cache menus and other parts of a web page - El Forum - 12-21-2007

[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


how to properly cache menus and other parts of a web page - El Forum - 12-21-2007

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


how to properly cache menus and other parts of a web page - El Forum - 12-22-2007

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