I've done quite a bit of research on Drupal performance, caching, have got memcache, APC, pressflow and so on all set up but have a problem.
I have written a custom module that works similar (I would imagine) to how the flag module would (I imagine) work for logged out users, i.e. store flagging actions to the session then sync those to the user account on login or registration. Now imagine being able to see how many items you had flagged somewhere in the header, these counts are pulled from the session. For logged in users, the counts are pulled from the DB / memcache.
So you can see the problem, with normal caching turned on, this doesn't work for logged out users since the whole page is cached. I've been experimenting with different cache settings, both from the interface and in custom blocks and have drawn a blank.
I realise it's a bit extravagant to have what amounts to dynamic content for logged out users but that's my business requirement. Does anyone have a suggestion for how I can get some kind of caching compromise?
Thank you in advance
Comments
couple of options
ESI or AJAX are 2 options to look at.
http://drupal.org/project/ajaxblocks
http://drupal.org/project/ajaxify_regions
http://drupal.org/project/esi OR https://github.com/dstuart/Drupal-ESI-Module/network
Pressflow & sessions
An additional problem, if I'm reading this right, is that you want to store data in session. Pressflow doesn't start sessions by default for anonymous users, so you'll need to account for that.
We've also had to store this kind of info in cookies before -- a little awkward, and runs up against data limits, but also cross-browser compatible and passes transparently to the back end.
Another option would be to use HTML5 web storage and submit the contents on login. You'd still have to account for IE6/7 with cookies, but then you get around the significant performance hit of starting a session for every anonymous user.
http://html5readiness.com/
http://www.w3.org/TR/webstorage/#storage
Apps like Sammy implement a storage layer that includes a fallback to cookies:
http://sammyjs.org/
http://sammyjs.org/docs/api/0.6.3/all#Sammy.Storage
Sammy JS is hawt.
Interesting options
Thanks for the swift answers, this gives me some ideas. I had no idea an ESI solution was available, very cool. I'll give sammy a serious look first, I already have some ideas for how that can work.
Regards Pressflow, yes right, I should do everything possible to stay away from needing sessions for logged out users. Thanks.
Regards Pressflow, yes right,
Whether you use sessions or cookies using AJAX or ESI, the effect is the same. The user gets a cookie and all future requests (until the cookie is gone) bypass Varnish. The only way to get around this is with HTML5.
--
Dave Hansen-Lange
Director of Technical Strategy, Advomatic.com
Pronouns: he/him/his
There's also file cache for
There's also file cache for use with /dev/shm.
ESIs
ESIs are very useful if you want to cache most of your page content but still need some areas to be dynamically served to all (even anonymous) users.
See: http://drupal.org/node/346347#comment-2586070
Another answer is: "with cookies and a bit of JavaScript magic." The flaggings of anonymous users are recorded (when page caching is in effect) in a cookie (as well as in the database). JavaScript code that's run on the page then looks into this cookie(s) and updates the links on the page to reflect their true state.
The exact mechanism is described here: http://drupal.org/node/991558#comment-3804822
--
Linux: Web Developer
Peter Bowey Computer Solutions
Australia: GMT+9:30
(¯`·..·[ Peter ]·..·´¯)