• Hi Jose,
    I just found this plugin, which seems to be interesting and could be a huge advantage for dynamic sites.
    I understand that you can prevent content from being cached using the shortcode. My questions is, would you consider having a functionality that would allow to cache elements with specific class or ID? It would be game-changer ex. for e-learning sites.

    For example my courses have static content and elements like progress bar, lesson, list etc. Those cannot be cached because they have to be updated based on user input. What if adding a certain class to a progress bar element would prevent it from being cached and so on. Is it even possible?

    BEst

    Simon

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Jose

    (@giuse)

    Hi Simon,

    this is a great idea. Yes, it’s possible, with some tricks, but it’s possible.
    The PRO version will give the possibility to exclude from the cache HTML elements by CSS selectors.
    For example, if you have something that looks like:

    <div id="sample-id" class="sample-class">
    ...
    </div>

    You will be able to exclude all that it’s inside the div and the div itself by asking Content No Cache to exclude #sample-id, or .sample-class, or whatever CSS selector defines the wrapper.

    I will be happy to give you a lifetime license as thanks for this brilliant idea.
    At the moment I can’t say when it will be ready. It may require up to 1-2 months because we are very busy at the moment, but I will be very happy to add this feature.

    However, for me, it’s hard to believe elements like progress bars aren’t updated with JavaScript. JavaScript is a client-side language, and you should not have any problem with the page cache.

    The page cache is widespread and it seems strange to me that there are still elements such as progress bars that do not take into account the cache
    If you have a plugin that adds this kind of elements via PHP, you should write the authors and make them notice they should use JS for those elements.

    Have a great day

    Jose

    @szymonfortuna

    Thread Starter szymonfortuna

    (@szymonfortuna)

    Hi Jose,
    I’d be happy to purchase a lifetime License. I’m using learndash. I’m not an IT person so I don’t know how to check if it works as you described. I just learned from different articles and others feedback that I should be excluding course / lesson / topics pages from caching to avoid having the static content and not seeing the updated list of completed lessons or the progress etc. Maybe it actually works… I’ll try to make some tests on my staging site.

    Nevertheless if the plugin had an option to add ex. “sample-class-to-exclude”. I could add that to any element from elementor or with a simple javascript code i could append it to any element that is generated by some other plugins (buddyboss, or maybe some events plugins etc.) and exclude elements that would need to load dynamically (prices / countdowns… just thinking out loud)

    It would be great if you’d work on it. I’ll be happy to follow any news! ??

    I totally agree with Simon! Being able to prevent caching of elements based on classes or IDs would be superb!

    Looking forward to it!

    Hi Jose

    This is a great feature, has it been implemented in the PRO version yet?

    @giuse

    Plugin Author Jose

    (@giuse)

    Hi @advwebmaster777, @szymonfortuna, @helderconde

    now with Content No Cache PRO v. 5.0.1 you can uncache the content by CSS class.
    It’s important to know that it will work only with the CSS classes that are added with Gutenberg, page builders, or classic editor. If the CSS class is written in a template file, then it will not work.

    Have a great day!

    Jose

    • This reply was modified 11 months, 2 weeks ago by Jose.
    Thread Starter szymonfortuna

    (@szymonfortuna)

    Hye Jose, thank you for the update. Just to clarify. Let’s ay if I have “Mark Complete” button or the progress bar from the learndash as a part of the page and the rest of the content on a lesson page I create with elementor… for those parts rom Learndas I won’t be able to exclude from caching…?

    Plugin Author Jose

    (@giuse)

    Hi Simon,

    said in other words, all that is saved into the database can work.

    The CSS classes that are printed by a PHP file will not work.

    I will try to make it clearer with an example.

    Imagine your theme displays a page through the file page.php where you have a code that looks like this:

    <?php
    /**
     * The Template for displaying single pages
     *
     */
    defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
    
    get_header();
    ?>
    <section id="primary" class="site-content">
    	<div id="content" class="content-no-cache-not-working" role="main">
    		<?php while ( have_posts() ) : the_post();
    		?>
    		<article <?php post_class(); ?>>
    				<?php the_content(); ?>
    		</article>
    		<?php endwhile; ?>
    	</div>
    </section>
    <?php get_footer();

    In this example if you want to uncache what is inside the element with the class “content-no-cache-not-working”, it will not work.

    Instead, what is printed by the_content() is taken from the database. Inside that content, you can have an element with a CSS class that can work.

    You add that kind of content when you edit a post, no matter if you do it with Gutenberg, a page builder, or Classic Editor.

    If for example you use Gutenberg and you assign a specific CSS class to a block, then that block will be uncached. The same if you assign the CSS class to an element of a page builder, or if you directly write HTML with Classic Editor.

    If it’s still not clear let me know.

    Have a great day!

    Jose

    Plugin Author Jose

    (@giuse)

    Hi Simon, again me. I’ve right now sent you an email.

    Have a great day!

    Jose

    @szymonfortuna

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Prevent caching for elements with specific classes or IDs’ is closed to new replies.