【问题标题】:Cached shopping cart after going back using the browser使用浏览器返回后缓存的购物车
【发布时间】:2015-01-09 18:45:41
【问题描述】:

我有一个自己创建的购物车。我的疑惑:如何解决缓存购物车的问题?我的意思是,当我进入产品页面并将其添加到购物车,然后使用浏览器按钮返回时,添加的产品不在购物车中。我必须刷新页面才能在购物车上看到它。

【问题讨论】:

    标签: symfony shopping-cart shopping


    【解决方案1】:

    作为一切顺利的起点,您应该在创建/更新购物车时在响应中设置适当的标头,这将指示浏览器不缓存它。

        $response = new Response();
        $response->headers->set('Cache-Control', 'no-store, no-cache, max-age=0, post-check=0, pre-check=0');
        $response->headers->set('Pragma', 'no-cache');
        return $response;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-07
      • 1970-01-01
      • 2012-09-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多