Caching a Drupal site with session-specific data on every page

时光毁灭记忆、已成空白 提交于 2019-12-06 06:50:17

问题


We have a site written in Drupal 6.

We want to use Drupal's caching mechanism to improve performance, but when we turned it on, we found problems because our site has session data displayed on every page. Drupal's caching system only works for static content page, and our session data effectively means that none of our pages are static.

We've come up with two solutions to this:

  1. Rewrite the block that shows the session data such that it loads the non-static data using Ajax, so that the main HTML content is then static. The down-sides of this are that it will mean quite a lot of work, and also that it will reduce functionality for non-Javascript-enabled users and speciality browsers (ie screen-readers).

  2. Move the session data to an iframe or similar. This just sounds wrong and I don't want to do it, but it would fix the problem, I think.

  3. or find an alternative caching system that will allow us to cache the site in a way that can deal with a there being a small block of dynamic data on every page. This is our preferred option, but we haven't been able to make any progress on finding anything, hence the question here.

So if anyone has any suggestions that would help us with option 3, please let us know. Thank you.

(ps - I know Drupal 7 does have an improved caching system which could help with this, but we're not ready to move to D7 yet)

[EDIT] Haven't made much progress on this, so I'll open it up to a bounty.

I've had a look into how Ubercart deals with a similar situation (since it's one of the most popular Drupal modules and has basically the same problem to solve as we do). They get around it by having the cart info block display static text when the user is not logged in (ie "Click here to view your basket"), and only showing the dynamic cart data on every page when the user is logged in. We don't feel this actually solves the problem; it just evades it, and that's not what we want. But I'm worried that if Ubercart has resorted to doing it this way, it may turn out to be the only option.


回答1:


Ajax Blocks.

A simpler Solution than Authcache is Ajax Blocks.

http://drupal.org/project/ajaxblocks

Works well, and from what I remember it handles users without js fairly well.




回答2:


Have you looked at the Authenticated User Page Caching (Authcache) module? It works similarly to what you describe in option 1 above.




回答3:


Another solution would be to use an ESI gate to render your pages as an assembly of blocks. There are a few projects around this, I'm no expert but searching google could give you some ideas.

PS: You will have the same problem with D7, caching is more or less the same.




回答4:


You might want to check out this module: http://drupal.org/project/blockcache_alter. I'm not sure if that will accomplish what you are looking for or not, but it might help give you insight into block caching.

Also, there are a lot of great performance resources here that could lead to something helpful: http://drupal.org/node/326504




回答5:


my problem is very similar. Depending on a session setting, the body background changes. I could add a class to the body tag with jQuery, but don't know if this performance will look fine.

I'll test it and report back.



来源:https://stackoverflow.com/questions/4511721/caching-a-drupal-site-with-session-specific-data-on-every-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!