Search code examples
amazon-web-serviceswoocommerceamazon-cloudfront

Issue with AWS Cloudfront and Woocommerce cart


I have an issue with Woocommerce on my site when I enable AWS Cloudfront CDN to speed up the site.

The site is hosted on an AWS EC2 Bitnami instance. No parts of the site are hosted in S3.

When Cloudfront is enabled and I add a product to the cart then press the “Proceed To Checkout” button from the shopping-cart, nothing happens, the browser just loads the shopping-cart page again. If I disable Cloudfront in the AWS for WordPress plugin then it works as expected and opens the checkout page. This happens in all browsers.

Also, if I update the quantity to add extra options then the shopping-cart page reloads with a message of "Your basket is empty". The cart icon still has a "1" against it, and when I press it the shopping-cart page comes back witht the item in place, but I have the same issue when pressing the “Proceed To Checkout” button.

Looking at the developer tools in the browser there are no indicators of any errors. This seems to be some caching or cookie issue.

I have a a Cloudfront policy that has Origin, Access-Control-Request-Method and Access-Control-Request-Headers whitelisted in headers to resolve CORS issues with font files This works as expected and the fonts load correctly, before this was in place font icons would not display and I'd get lots of 404 errors.

Following some answers from this Cloudfront + Woocommerce - cart not updating SO post I tried whitelisting all cookies, and whitelisting jsut wp_woocommerce_session_* which I added while debugging this issue. Neither of these options made any difference.

The only way I can get it to work is by disabling Cloudfront. The site is slow to load without it though and SEO results are compromised.

Any idea what settings I need to change in order to get this to work?


Solution

  • In the end I ditched the official AWS plugin, and used another (free) AWS CDN specific plugin that did all the configuration and worked out of the box.