简体   繁体   中英

Caching one section of a CodeIgniter page

I'm using codeigniter to create a web app. I'm creating the drop down menus in the header. These are included on every page using load->view(). To populate the menus some quite complex SQL is used. The contents on the menu will change infrequently (once/twice a week), whereas the rest of the data on the page is constantly changing.

Therefore I don't want the overhead of running this SQL everytime a page is loaded. I looked at using CI caching but its on a page level. I really only want to cache a small segment.

What do you think the best approach to this is? I thought about writing this to a text file, but then you'd have to manually run the code to write this every so often.

查看查询缓存页面,或者您也可以使用缓存库来缓存页面的部分(首选方法恕我直言),看看KhCache

Another good caching library I have found is from Phil Sturgeon. http://github.com/philsturgeon/codeigniter-cache

It allows caching models, libraries, or just partial caching like you describe.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM