缓存产品页面上的动态内容?

时间:2017-04-07 07:54:33

标签: php

有一个使用Memcached的完全缓存产品页面的电子商务应用。因此,控制器通过密钥检查页面是否被缓存。如果缓存,从内存输出html需要1.5毫秒。

$product_rendered = $this->cache->get($key);
if(empty($product_rendered)) {
 //$product ... Get data for product
 $this->cache->set($key, $product, 86400);
}

但现在有一个动态内容,每15分钟在网站上更改一次。交货条款,产品供应,运输成本等。

问题是如何在用户加载页面时更改缓存内容中的动态信息?

不想在页面加载时使用AJAX。 可以通过替换缓存的product_info($ product_rendered)中的子字符串来完成,如:

$output = sprintf($product_rendered, $dynamic_content);

也许有更好的选择?

0 个答案:

没有答案