Exclude specific content from being cached

Normally, if a web page is served by the cache, its content will be always the same until the cache is deleted.

And if you need to serve dynamic content without renouncing to the page cache?

Here is the easiest solution to show dynamic content even with full page cache:

  • Install Content No Cache
  • Create a new element “Content No Cache”
  • Copy the shortcode that you will see in the section “Shortcode”. It will look like [content_no_cache id=”3328″]. The parameter “id” is the ID of the content element (in this example 3328).
  • Add the shortcode to the page where you want to display that content.

Here you have an example. The following number is randomly generated via PHP:

Refresh the page, you will see always a different number. But this page is served by Cloudflare, and when the cache of Cloudflare is not available it’s served by the cache created by WP Fastest Cache.