Back to Community

How to Exclude Dynamic Content from WP-Optimize Page Caching

20 threads Sep 16, 2025

Content

One of the most common challenges when using page caching is handling dynamic content. Elements like shopping cart counters, live news feeds, or personalized user data need to update frequently, but a full-page cache can prevent this from happening. This guide explains why this occurs and the primary methods available in WP-Optimize to work around it.

Why Dynamic Content Gets Cached

WP-Optimize's page cache works by saving a static HTML version of your pages. This is excellent for performance, as it drastically reduces server load. However, it means that any part of the page that is unique to a user or changes on every page load—like a cart total or a random post widget—will be 'frozen' in its cached state until the entire page's cache is cleared or expires.

Available Solutions for Excluding Content

Currently, WP-Optimize operates primarily at the page level. This means the main strategies involve excluding entire pages or URLs from caching. While a feature to exclude specific sections of a page (often called fragment caching) is confirmed to be in development, it is not yet available. Here are the most effective workarounds based on community support threads.

1. Exclude Specific URLs

The most straightforward method is to exclude the entire URL where the dynamic content appears. This is ideal for pages like checkout, cart, or a dedicated member's area.

  • How to do it: Navigate to WP-Optimize > Cache > Advanced Settings.
  • Find the "URLs to exclude from caching" text box.
  • Enter the specific path, such as /cart/ or /checkout/.
  • You can also use a wildcard (*) to match multiple pages, e.g., /members/* or /page/* to exclude pagination archives.

2. Use Conditional Tags (For Advanced Users)

For more programmatic control, you can use WordPress conditional tags to target specific pages, like the homepage or blog posts page.

  • How to do it: In the Advanced Settings tab, find the "Conditional tags to exclude from caching" field.
  • Enter a WordPress conditional function like is_front_page() to exclude the homepage or is_cart() if you are using WooCommerce.
  • This method requires familiarity with WordPress's conditional tags.

3. Configure Cookie-Based Cache Exclusion

If your dynamic content is user-specific and controlled by cookies (e.g., a logged-in user's dashboard), you can prevent caching when certain cookies are present.

  • How to do it: In the Advanced Settings tab, find the section for "Cookies which, if present, will prevent caching".
  • Add the name of the specific cookie that triggers the dynamic content. You may need to consult your theme or plugin documentation to identify the correct cookie name.

Current Limitations and Workarounds

It's important to note the current limitations of the plugin, as confirmed in numerous support threads:

  • No Widget or Block Exclusion: You cannot exclude a specific widget, block, or HTML element (e.g., a .div or CSS class) from caching. The entire page must be excluded.
  • No Plugin Exclusion: You cannot exclude an entire plugin from caching. Instead, you must exclude the specific pages where that plugin's functionality appears.
  • Manual Cache Purging: For elements that update on a schedule (e.g., a monthly calendar), you may need to manually purge the cache via WP-Optimize > Cache > Purge cache when the content changes.

Looking Forward: Fragment Caching

The 'WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance' team has acknowledged the high demand for a feature that would allow users to exclude only parts of a page from the cache. This functionality is on their development roadmap for a future release. For now, the URL and conditional exclusion methods are the most effective tools available.

By understanding these methods, you can strategically configure caching to maintain site speed while ensuring critical dynamic elements remain functional for your users.

Related Support Threads Support