Welcome Guest, Not a member yet? Register   Sign In
Caching user specific content

I've been developing a large multi-user application based on CodeIgniter for some time and it's come to the point where it could really do with a little optimizing. Just one of these things if of course caching.

The problem is that I need to be able to cache pages which show different content to different users. Here's a simplified example...

Lets say there is the page /articles/view/102 which takes you to an article. In the sidebar of this page is content which is specifically related to the user who's logged in at that time. To simply use $this->output->cache(n) would mean that when user 2 comes along they would see the version which was cached when user 1 was logged in, so it wouldn't be their stuff in the sidebar.

How can I get around this? My only solution so far would be to append the logged in user ID to the end of every URL to make it unique, but that's far from optimal!

Any suggestions?


Use Phil Sturgeons' cache library to cache partials.

This is very easy if you're pages are generated using a template with multiple views (so you can cache per view). The library allows you to define the id of the cache file yourself, so it's very simple to include the userid in that name, and cache only the sidebar view for each user specific.

Theme © iAndrew 2016 - Forum software by © MyBB