2

i have a cart controller. in add and remove methods i change products that are stored in session and redirect back to cart page.

the problem i have that on production environment it works only one time and then does nothing like it caches redirects and ignores logic.(cart page just refreshes like nothing was changed)

/**
 * @Route("/", name="cart_index")
 * @param Request $request
 * @return array
 */
public function indexAction(Request $request)
{
   $cart = $this->get('cart');
   $products = $cart->getProductPages();
   //output cart
}


/**
 * @Route("/add/{id}", name="cart_add")
 * @param $id
 * @return \Symfony\Component\HttpFoundation\RedirectResponse
 */
public function addAction($id)
{
    $this->get('cart')->addProduct($id);
    return $this->redirect($this->generateUrl('cart_index'));
}

/**
 * @Route("/remove/{id}", name="cart_remove")
 * @param $id
 * @return \Symfony\Component\HttpFoundation\RedirectResponse
 */
public function removeAction($id)
{
    $this->get('cart')->removeProduct($id);
    return $this->redirect($this->generateUrl('cart_index'));
}

and the most interesting that it even ignores the request request

on the dev environment everything works great.

KoSMoS
  • 534
  • 2
  • 5
  • 19
  • 1
    Read this - [how to prevent cache in symfony2](http://stackoverflow.com/questions/16753142/redirecting-and-preventing-cache-in-symfony2) – Peter Popelyshko Mar 20 '15 at 10:36

0 Answers0