LearnDash Design & Tutorials

LearnDash Design & Tutorials

LearnDash & WP Rocket ๐Ÿš€: The Perfect Performance Setup

Affiliate Disclosure: We may be compensated if you use our links to make a purchase. We are extremely selective in who we partner with & only recommend products we believe in. Our affiliate relationships do not influence our recommendations.

Are you using WP Rocket with LearnDash? That’s a great combination, but there are some things you should know about how to set it up. Performance settings & caching can speed up your site, but if not tailored correctly, can also cause issues on LearnDash sites (or any dynamic site in general).

This article will explain the WP Rocket settings that relate to LearnDash, and provide recommendations to make the two plugins work best together.

I personally use WP Rocket on all of the websites I manage. For 4+ years, it has been the best WordPress performance plugin, and I believe it to be the best to use with LearnDash.

I’m an affiliate with WP Rocket, and if you use my link to purchase it, it helps me continue to create free content like this. Buy WP Rocket โ†’

TABLE OF CONTENTS

Caveats

  • I’m not going to cover all WP Rocket settings in this article… only the ones that relate to LearnDash performance. There is no one-size-fits-all configuration for WP Rocket so I can’t universally recommend the perfect setup. It depends on many variables that are unique to your site.
  • It’s likely that the settings I’m recommending will not provide the absolute best performance possible. I’m trying to achieve good performance, while making sure LearnDash functions properly and all of its features work as expected. If you get too aggressive with performance optimizations, you risk breaking functionality.
  • A performance plugin is only one factor in the overall performance of your LearnDash site. You also need quality LearnDash hosting, among other things, to maintain a well-performing site.

Now let’s dive into the settings.

Cache

Mobile Cache

In general, enabling mobile cache is a good thingโ€”I recommend it. As WP Rocket states, for most theme & site configurations, enabling separate cache files for mobile devices is not necessary, so keep this option disabled.

WP Rocket mobile cache file settings for LearnDash

User Cache

This is a bit of a tricky one. It looks like WP Rocket created this feature for membership sites and sites with user-restricted content. You might think LearnDash fits into these categories, and you’re not wrong.

But I think this option is better suited for traditional membership sites that restrict entire articles & page content from users, based on membership level. I don’t think it was designed for LMS platforms that track user progress, show progress bars, show checkmarks for completed lessons, etc.

It’s possible that enabling this setting could help speed up your LearnDash site, but I think it’s risky. It might work for some LearnDash features (course pages, group-protected content on posts & pages), but it is likely to cause issues on quizzes, my account pages and others.

Since there is no granular control over when to use it, I recommend keeping user cache disabled.

WP Rocket user cache disabled in settings

WARNING
Some users have reported quizzes getting stuck & not finalizing results when they enable the user cache optionโ€”another reason we recommend keeping it disabled.

โœ… Enable caching for mobile devices
โŒ Separate cache files for mobile devices
โŒ Enable caching for logged-in WordPress users

File Optimization

CSS Files

WP Rocket CSS file settings for LearnDash

Minifying CSS files is a good thing, however, I often don’t enable this option within WP Rocket for one main reason. If you’re using quality themes & plugins, all of your CSS files are already minified. Theme & plugin developers should be minifying their files already, and most of the good ones do.

LearnDash, Elementor, BuddyBoss, Design Upgrade, all of Uncanny Owl’s plugins… they all minify their CSS already. So there’s usually no need to enable this option.

Combining CSS files usually doesn’t cause any issues with LearnDash or your design, but in a majority of cases, it leads to slower performance. It should remain disabled.

Optimizing CSS delivery should be tested if enabled, but generally, it’s a good option to enable. It doesn’t necessarily relate to LearnDash, but it will help your perceived performance, as well as your scores on various site speed tests.

Enabling this option will create a unique set of CSS specific for your site, and since there are an infinite number of possibilities here, you should test this on a staging site first. It likely won’t cause issues with LearnDash, but it could affect the overall design of other areas of your site.

โŒ Minify CSS files
โŒ Combine CSS files
โœ… Optimize CSS delivery

JavaScript Files

WP Rocket JavaScript file settings for LearnDash

Minifying JavaScript files is similar to minifying CSSโ€”it’s generally a good thing, but likely already done by your theme & plugins. Enabling it here only opens up more opportunity for issues.

Combining JavaScript files can definitely cause LearnDash issues. I have helped numerous users who were experiencing LearnDash issues, and disabling this option solved their problems.

Loading JavaScript deferred is a good idea, but it should also be tested to ensure it doesn’t cause issues on your site. Most JavaScript can be deferred without any issues, but there might be some JavaScript that needs to be loaded right away, before anything else. One example is jQuery, which you see excluded in the image above.

I keep the default URL (regex) that WP Rocket puts in there. Basically, it just excludes jQuery from being deferred because it is often used with many themes & plugins, and it needs to load before a lot of other code.

/jquery-?[0-9.]*(.min|.slim|.slim.min)?.js

I have not tested delaying JavaScript execution, but I suspect it could cause issues. Some of LearnDash’s core functionality relies upon JavaScript, and if you delay its execution, you are likely to experience issues with user progress (and possibly other things). Even WP Rocket warns that it’s an advanced option that should be used with care.

โŒ Minify JavaScript files
โŒ Combine JavaScript files
โœ… Load JavaScript deferred
โŒ Delay JavaScript execution

Advanced Rules

Never Cache URL(s)

IMPORTANT
In almost all cases, you should disable caching on all LearnDash pages.

Because LearnDash outputs dynamic content on almost all of its pages (content that is updated on every page load and/or is unique to each user), you should not cache these pages. It will cause your users to see outdated or incorrect content, struggle with course progression, possibly have trouble logging in, and other issues.

What is considered “a LearnDash page?”

  • all course pages
  • all lesson pages
  • all topic pages
  • all quiz pages
  • all group pages
  • all assignment & essay pages
  • any page with a LearnDash block or shortcode on it. For example:
    • the LearnDash Profile block or [ld_profile]
    • the LearnDash Course List block or [ld_course_list]
    • any [student], [visitor] or other conditional shortcode or block
    • all Uncanny Toolkit, Uncanny Groups or Tin Canny Reporting shortcodes
    • the [ld_propanel] shortcode
    • a custom login page (anything other than wp-login.php)

WP Rocket gives us the ability to exclude these pages from being cached.

WP Rocket never cache URLs settings for LearnDash

You can add this to theย Never Cache URL(s) area in WP Rocket.

/courses/(.*)
/lessons/(.*)
/topic/(.*)
/quizzes/(.*)
/groups/(.*)

โ—Two important caveats:

  1. This assumes you did not change your LearnDash permalinks on theย Settings > Permalinks page. If you did, refer back to your changes to update your URLs here.
  2. This is not an exhaustive list. In addition, you need to add all other pages that include LearnDash blocks/shortcodes.

For example, if you created a “my courses” page at yoursite.com/my-courses/, you would add /my-courses/ to that list.

If you added the LearnDash Profile block to your WooCommerce My Account page, and you’re using the default WooCommerce My Account page, you would add /my-account/ to that list.

Cloudflare

WP Rocket Cloudflare setting enabled in settings

If you’re using Cloudflare, be sure to enable the Cloudflare add-on by flipping the switch forย Add-on status to ON. Then click the Modify Options button to enter your Cloudflare account info.

I recommend enabling theย Optimal settings option.

WP Rocket Cloudflare settings enabled


I personally use WP Rocket on all of the websites I manage. For 4+ years, it has been the best WordPress performance plugin, and I believe it to be the best to use with LearnDash.

I’m an affiliate with WP Rocket, and if you use my link to purchase it, it helps me continue to create free content like this. Buy WP Rocket โ†’

That does it for all the WP Rocket settings we’re going to cover related to LearnDash. Use these recommendations as a baseline for your LearnDash site, but if you’re comfortable testing things in a staging environment, feel free to try and optimize them further. Just be sure to test thoroughly, test as if you were a user (not an admin) AND as a visitor who is not logged in.

Special Thanks & Feedback

Special thanks to Adeel Raza for sharing his specific WP Rocket settings for LearnDash in the Facebook group. His post, and the level of interest in it, is what inspired me to put this together.

If you have any questions or feedback about your LearnDash-WP Rocket setup, please let me know in the comments. Do you disagree with any of my recommendations? Do you set up WP Rocket differently? I want to know. Let’s discuss.

Sponsor

Finally Revealed...

NEW breakthrough solution allows you to IMMEDIATELY GROW student engagement and revenue per student by creating a state of the art mobile application in UNDER 60 MINUTES without ANY coding knowledge!

5 out of 5 stars

Proven and tested by over 1,000 LearnDash customers.

Get your LearnDash Mobile App โ†’

Previous

LearnDash & the SG Optimizer Plugin ๐Ÿ™…โ€โ™€๏ธ

Next

LearnDash Focus Mode: Sticky Header on Mobile

12 Comments

  1. I am happy to see that the Facebook post became a starting point for this awesome article. Very neatly organized, awesome work as always Dave ๐Ÿ™‚
    Cheers!

  2. Victor

    Thank you for this. Very helpful. Testing on my site now

    • You’re welcome. I’d love to hear back from you on how it goes, if you’re up for sharing. Every site is unique so getting feedback from different people with varying setups is really helpful to the community. Especially if you experience any LearnDash issues, please report back if you can ๐Ÿ™.

  3. Hi, great post! I was wondering, is preloading of all pages, except the ‘never cache URL’ from Learndash preferred? If so, what time of lifespan do you use?

    regards,

    Ron

    • Hi Ron. Good questions.

      I enable preloading. In general, it’s a good thing. It causes your server to do work in advance, so that when users hit your server, the server is more prepared to give the user what they are requesting… which translates into a faster experience for the user.

      I’m pretty sure anything you add to the Never Cache URL(s) section will be excluded from preloading automatically.

      I follow WP Rocket’s advice and use 10 hours as my lifespan. If you click the “Why?” link in the help text, they give a nice explanation why 10 hours is a good place to start. But if you’re on mediocre or crappy hosting, 10 hours could cause issues, and you might need to increase it. If you notice issues, I’d increase it in 3 hour increments until problems subside.

  4. Hi Dave,
    Thanks for ypur explanation.

    The WP Rocket explanation however is not totally clear to me.
    One of my clients does have a WP Woocommerce webshop and the lifespan setting are 0. Note that I just took over the maintenance of the webshop so I was wondering why it is 0.

    thanx!

    Regards,

    Ron

    • According to the WP Rocket docs, a cron job runs every hour to check and see if WP Rocket should clear the cache off of your server. Then, with preloading enabled, WP Rocket will re-cache anything that you have not told it to exclude.

      So setting the cache lifespan to 10 would mean WP Rocket deletes its cache files, and grabs a new copy to cache, once every 10 hours. Setting it to 0 would mean WP Rocket is deleting the cache every single hour.

      To me, this seems really aggressive, unless you are making changes to your site every hour of the day. But keep in mind, some WooCommerce pages are going to be excluded from cache. WP Rocket automatically excludes the WooCommerce cart, checkout & my account pages, so cache lifespan does not apply to them.

      If you’re using somewhat standard product pages (title, images, description, price, sku… basically, static info that can be cached), you should be ok to cache these pages, and ok to update the cache for them every 10 hours (or more). But if you get multiple reviews per day and want them to appear for new visitors right away, or you use stock management and want updated inventory to be displayed in real time, those might warrant a 0 cache lifespan. That would mean they’ll be updated every hour.

  5. Hi Dave,

    Thanx for the clarification. Really helpful!

    Now I know how to configure my clent websites the proper way.

    Best regards,

    Ron

  6. JP

    Hi Dave,

    in Loading JavaScript deferred and addingyour recommendations, the image is blury.
    so, after (.min and .slim) are those an l or | or ?
    Thanks,

    JP

    • Hi JP,

      They are vertical lines (|). Here’s the code in text form:

      /jquery-?[0-9.]*(.min|.slim|.slim.min)?.js

      It’s only needed if your site is loading jQuery. Some sites don’t, but many do. jQuery is used by a lot of themes, as well as many plugins, so it’s fairly common to see it loaded on many sites.

Leave a Reply

Your email address will not be published. Required fields are marked *

Powered by WordPress & Theme by Anders Norén