WooCommerce performance tips

Have you noticed that your WooCommerce site is running slow? Before asking your web host to increase resources read this article.

Please note that from WooCommerce 2.5.x and above WooCommerce uses custom table to store data rather than the options table for performance and scalability reasons.

WooCommerce stores in wp_options customer’s shopping cart information. As a result if you have many number of visitors in your website wp_options might become really big. This affects your website’s performance.

Another reason for large number of wc_session records is robots. This happens because many search engines crawl your website plenty times during the day.

For example a search engine visits a link such as the following:


This url adds the product with ID 11 to cart, which means that a wc_session is going to be created and stored in wp_options. Imagine what happens when you have thousands of products in your eshop and search engines crawls your website all the time.

In order to avoid this very usual scenario simply add the following lines in your robots.txt file

This will prevent search engines to crawl urls that contain add-to-cart parameters and won’t add wc_session records in wp_options.

[box type=”note”]You may empty wc_session records from your wp-admin. Login to your Dashboard and then go to WooCommerce > System Status and click in the tab Tools. In the section Customer Sessions press Clear all sessions.[/box]

I am message box. Click edit button to change this text.

Which option is the best?

In the end, no matter how big your site is or how many visitors you have per day,  wp_options sooner or later will grow big some time.

You should really take into consideration which option is the best to avoid such an experience. I would suggest to set up a cron job in order to clear wc_sessions. It’s on you to decide how frequently this job will be executed. For example in a client’s website with 3000 products and about 1000 visitors per day I’ve setup this cron job to run twice a day.

Try to avoid running this script during rush hours.

Here is the MySQL script to clear wc_sessions

I am going to talk in another post about setting up effective cron jobs in WordPress

Development Tips, WooCommerce
Previous Post
New WooCommerce plugin for Online Book Store!
Next Post
WooCommerce Orphan Variations