• Hi,

    I’m trying to add some dynamic content to page, but I have problem with it. If I delete cache and refresh the page, it works fine, but after next refresh it shows placeholder instead of the dynamic content (same for next refresh).

    My code is:

    <h3>aa</h3>
    					<?php
    
    					define( 'TAG', 'aa' ); // Change this to a secret placeholder tag
    					if ( TAG != '' ) {
    						function dynamic_cache_test_safety( $safety ) {
    							return 1;
    						}
    						add_cacheaction( 'wpsc_cachedata_safety', 'dynamic_cache_test_safety' );
    
    						function dynamic_cache_test_filter( &$cachedata) {
    							return str_replace( TAG, "time" . time(), $cachedata );
    						}
    						add_cacheaction( 'wpsc_cachedata', 'dynamic_cache_test_filter' );
    
    						function dynamic_cache_test_template_tag() {
    							echo TAG; // This is the template tag
    						}
    
    						function dynamic_cache_test_init() {
    							add_action( 'wp_footer', 'dynamic_cache_test_template_tag' );
    						}
    						add_cacheaction( 'add_cacheaction', 'dynamic_cache_test_init' );
    					}
    					?>

    Can you help me with this problem? Thanks!

    https://wordpress.org/plugins/wp-super-cache/

Viewing 1 replies (of 1 total)
  • First of all, I recommend a way more complex tag than “aa”. One simple typo could result in “aa” anywhere on a page or forgetting to capitalize a name like “aaron” would also trigger your dynamic caching.

    All of the code below the <h3>aa</h3> should be in a PHP file within the plugins folder of the WP Super Cache plugin. Is that the case? You also need to enable “Dynamic caching” on the Advanced tab of the WP Super Cache settings page. It’s a checkbox near the top of the page.

Viewing 1 replies (of 1 total)

The topic ‘Dynamic content and placeholder tag’ is closed to new replies.