在每个页面上缓存具有特定于会话的数据的 Drupal 站点 [英] Caching a Drupal site with session-specific data on every page

查看:15
本文介绍了在每个页面上缓存具有特定于会话的数据的 Drupal 站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个用 Drupal 6 编写的网站.

We have a site written in Drupal 6.

我们想使用 Drupal 的缓存机制来提高性能,但是当我们打开它时,我们发现了问题,因为我们的站点在每个页面上都显示了会话数据.Drupal 的缓存系统仅适用于静态内容页面,而我们的会话数据实际上意味着我们的页面都不是静态的.

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. 重写显示会话数据的块,使其使用 Ajax 加载非静态数据,以便主 HTML 内容是静态的.这样做的缺点是,这意味着需要做大量工作,而且还会减少不支持 Javascript 的用户和专业浏览器(即屏幕阅读器)的功能.

  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).

将会话数据移动到 iframe 或类似的.这听起来不对,我不想这样做,但我认为它可以解决问题.

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.

或者找到一个替代的缓存系统,使我们能够以一种可以处理每个页面上存在一小块动态数据的方式缓存站点.这是我们的首选选项,但我们一直无法在查找任何内容方面取得任何进展,因此问题出现在这里.

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.

因此,如果有人有任何建议可以帮助我们处理选项 3,请告诉我们.谢谢.

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

(ps - 我知道 Drupal 7 确实有一个改进的缓存系统,可以帮助解决这个问题,但我们还没有准备好迁移到 D7)

(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)

在这方面没有取得太大进展,所以我会悬赏.

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

我研究了 Ubercart 如何处理类似情况(因为它是最受欢迎的 Drupal 模块之一,并且与我们解决的问题基本相同).他们通过在用户未登录时让购物车信息块显示静态文本(即单击此处查看您的购物车")来绕过它,并且仅在用户登录时在每个页面上显示动态购物车数据.我们不要觉得这实际上解决了问题;它只是逃避它,这不是我们想要的.但我担心如果 Ubercart 采取这种方式,它可能会成为唯一的选择.

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.

推荐答案

Ajax 块.

比 Authcache 更简单的解决方案是 Ajax 块.

A simpler Solution than Authcache is Ajax Blocks.

http://drupal.org/project/ajaxblocks

效果很好,我记得它可以很好地处理没有 js 的用户.

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

这篇关于在每个页面上缓存具有特定于会话的数据的 Drupal 站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆