Magento的+光油 - 逻辑的商店,打开和关闭在特定时间 [英] Magento + Varnish - Logic for stores that open and close at specific Times

查看:110
本文介绍了Magento的+光油 - 逻辑的商店,打开和关闭在特定时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近部署了我的Magento的网站,并开始使用清漆就可以了。

I recently deployed my Magento site and started using Varnish on it.

不过,我们确实有一些PHP逻辑放在每一个店的开闭按钮(他们是在工作时间开放),和它单曲关闭后,应该收到任何订单。 同时,我们有上的按钮添加到购物车,告知顾客该店开业时的逻辑。

However, we do have some PHP logic that place an open and close button on each of the stores (they are open on working times), and after it`s closed it should received any orders. Also, we have logics on the buttons 'Add to Cart', to inform the customer when the store is opened.

这里的问题是,如果我所服务清漆的网页,加载时间确实是了不起的,然而,当商店被打开(或关闭),该网页不刷新(当然)。

The issue here is that if I serve the pages with VArnish, the loading time indeed is marvelous, however when the store gets opened (or closed), the page is not refreshed (of course).

这将是在这种情况下,最好的做法?

Which would be a best practice in this case?

  • 在写一个AJAX逻辑来获得后端这些动态信息
  • 运行光油清除具有此逻辑的所有页面,由当时的店被打开
  • 有一个较低的TTL集(这将减少高速缓存命中)。

非常感谢你的帮助。

最好的问候, 毛。

推荐答案

有关存储在HTML每家店的开启和关闭时间,并使用JavaScript来显示用户的当前状态是什么?这样,你可以使用缓存,而且还有你提到的动态部分。

What about storing the open and close times of each store in the html and use javascript to show the current status to the user? That way you can use the cache and still have the dynamic parts that you mentioned.

例(不工作,主要是伪code):

Example (will not work, mostly pseudo code):

<p id="open" data-open-start="8:00 UTC" data-open-end="16:00 UTC">We are open between 8:00 UTC and 16:00 UTC</p>

<script>
  // assuming JQuery
  var open_start_time = [get data-open-start-time and parse it]
  var open_end_time = [get data-open-end-time and parse it]
  // some time zone conversions...
  if (currentTime >= open_start_time && currentTime <= open_end_time) {
    $('p#open').text('we are open!');
  } else {
    $('p#open').text('sorry, we are closed!');
  }
</script>

这篇关于Magento的+光油 - 逻辑的商店,打开和关闭在特定时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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