Caching with Leaky Paywall (i.e WP Engine)
Leaky Paywall can/will work with hosts that cache heavily:
AND caching plugins (like WP Super Cache, WP Rocket, etc), but it all depends on how it’s setup. Any caching plugin you use will have a lot of different setup options, and the sort of plugins you’re using (WooCommerce, iThemes Exchange, Leaky Paywall, etc) will often times determine what kinds of caching you should be using. Any sort of caching that simply caches the HTML output of a page is pretty basic and often has problems. The best caching to use with any sort of membership management sites like Leaky Paywall is backend object caching.
1. Enable “Alternative Subscription Handling”
In Leaky Paywall > Settings > Subscriptions click the “Alternative Subscription Handling” checkbox to enable it.
2. Set the post and page container selectors
By default Leaky Paywall uses the CSS selector "article .entry-content" to determine where your content lives on the screen. If your theme uses a different CSS selector, enter it here. You can enter a different selector for posts and pages in case your theme uses different selectors for each type of content.
You can use your browser's inspector to find the selector that contains your post content. Since themes are different you will need to find your specific article container. Here's how to find it:
- Go to an article page
- In your browser menu choose View/Developer/Inspect Elements (or similar depending on your browser)
- Highlight some text that should be near where the subscription nag would display (near the end of your excerpt text)
- Right click on on the highlighted text and choose Inspect
- In the inspector window you will need to find the container that contains your content. Ex: td-post-content (it should be close to the highlighted line)
- In the screenshot below the correct value to use for the post container selector is ".entry-content" (note the period in front of the name)
- When you find the post container name you need to add a "." in front of the container name. In the example below, the correct value to use for the post container selector is ".td-post-content"
- Add the container name to the Leaky Paywall Post Container fields
- That should do it. Test access to make sure restrictions are working properly
3. Set the number of Lead In Elements
Set the number of HTML elements (paragraphs, images, etc.) to show before displaying the subscribe nag.
4. Make sure your theme is using the body_class() function
WordPress themes should use the body_class() function to add default WordPress classes to the <body> tag of your site. This is standard on almost every WordPress theme and is required for Leaky Paywall to work. It will look like this in your theme:
<body <?php body_class(); ?>>
For more information, please see https://developer.wordpress.org/reference/functions/body_class/
5. If it's still not working with WP Engine, disable the cookie from caching on live site
Ask WP Engine support to “disable this cookie from caching on live site”:
For single site: issuem_lp
For multisite: issuem_lp_<site id>
You may also need to whitelist certain URLs, for instance, if you’re using the IssueM plugin, you could white list this URL:
We use Nginx, PHP-FPM, and Redis caching on our sites and have never had any trouble with any e-commerce or membership solution.
We have also seen success with the Fastest Cache plugin.
Caching for Logged In Users
We recommend turning off caching for logged in users. However, here is more information on the subject if you are using Edge-side caching.
OpenLiteSpeed (OLS) served via Cloudflare Automatic Platform Optimization (APO) is a combination of server software and caching technology that works in conjunction with Cloudflare's content delivery network (CDN) to accelerate the performance of WordPress websites. When it comes to WordPress logged-in users, there are a few important considerations:
- Cloudflare APO caching: Cloudflare APO is primarily designed to cache and serve static content to anonymous visitors, improving their page load times. By default, Cloudflare APO bypasses the cache for logged-in WordPress users to ensure they see the latest dynamic content and personalized experiences. This means that when a user is logged in, the caching is disabled for their requests, and the content is generated dynamically.
- OpenLiteSpeed caching: OpenLiteSpeed is a high-performance web server that can also provide additional caching capabilities for WordPress sites. It has its own caching mechanism, known as LiteSpeed Cache, which is separate from Cloudflare's cache. When a user is logged in, OpenLiteSpeed can cache certain dynamic content on the server side to improve the response time for subsequent requests from the same user. This can help reduce the load on the WordPress backend and improve the overall performance.
- Edge-side includes (ESI): Another important feature of OpenLiteSpeed and Cloudflare APO is the support for Edge-side Includes (ESI). ESI allows for dynamic content to be selectively cached and served from the CDN, while other parts of the page that are specific to the logged-in user can be fetched dynamically from the origin server (WordPress backend). This approach allows for a balance between caching static components and ensuring personalized content is served correctly.
In summary, when a WordPress user is logged in and accessing a site served via OpenLiteSpeed and Cloudflare APO:
- Cloudflare APO bypasses the cache for logged-in users, ensuring they see the latest dynamic content.
- OpenLiteSpeed's caching mechanism can still cache certain dynamic content on the server side to improve subsequent request times.
- Edge-side Includes (ESI) can be utilized to selectively cache and serve static components while fetching personalized content from the origin server.