开发者

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.


Take a look at the query caching page, or alternatively you can use a caching library to cache sections of a page (preferred method IMHO) take a look at 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜