在每个页面上缓存包含特定于会话的数据的 Drupal 站点

发布于 2024-10-08 12:55:52 字数 859 浏览 4 评论 0原文

我们有一个用 Drupal 6 编写的站点。

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

我们对此提出了两种解决方案:

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

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

  3. 或者找到一个替代的缓存系统,该系统允许我们以一种可以处理每个页面上都有一小块动态数据的方式缓存站点。这是我们的首选选项,但我们在查找任何内容方面都没有取得任何进展,因此出现了这里的问题。

因此,如果有人对选项 3 有任何帮助,请告诉我们。谢谢。

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

[编辑] 在这方面还没有取得太大进展,所以我将开放赏金。

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

别忘他 2024-10-15 12:55:52

您是否查看过经过身份验证的用户页面缓存 (Authcache) 模块?它的工作原理与您在上面选项 1 中描述的类似。

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

雨夜星沙 2024-10-15 12:55:52

阿贾克斯块。

比 Authcache 更简单的解决方案是 Ajax Blocks。

http://drupal.org/project/ajaxblocks

效果很好,据我记得它可以处理用户而无需js相当好。

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.

哀由 2024-10-15 12:55:52

另一种解决方案是使用 ESI 门将页面呈现为块的集合。有一些与此相关的项目,我不是专家,但搜索谷歌可以给你一些想法。

PS:使用 D7 也会遇到同样的问题,缓存或多或少是相同的。

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.

寻梦旅人 2024-10-15 12:55:52

您可能想查看此模块:http://drupal.org/project/blockcache_alter。我不确定这是否能实现您正在寻找的目标,但它可能有助于您深入了解块缓存。

此外,这里还有很多很棒的性能资源,可能会带来一些有用的东西:http://drupal.org/node /326504

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

瀞厅☆埖开 2024-10-15 12:55:52

我的问题非常相似。根据会话设置,正文背景会发生变化。我可以使用 jQuery 将一个类添加到 body 标记,但不知道这种性能是否会很好。

我会测试它并报告回来。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文