Legend:

Note: from version 1.4 this functionality will be disabled by default. You will have to enable it on the settings page.

383

384

There are 2 ways of doing this. You can use Javascript to draw the part of the page you want to keep dynamic. That's what Google Adsense and many widgets from external sites do. Or you can use a WP Super Cache tag to do the job but you can't use mod_rewrite mode caching. You have to switch to PHP or legacy caching.

385

386

There are a few ways to do this, you can have functions that stay dynamic or you can include other files on every page load. To execute PHP code on every page load you can use either the "dynamic-cached-content", "mfunc", or "mclude" tags. The "dynamic-cached-content" tag is easier to use but the other tags can still be used. Make sure you duplicate the PHP code when using these tags. The first code is executed when the page is cached, while the second chunk of code is executed when the cached page is served to the next visitor.

382

Note: this functionality is disabled by default. You will have to enable it on the Advanced Settings page.

383

384

There are 2 ways of doing this. You can use Javascript to draw the part of the page you want to keep dynamic. That's what Google Adsense and many widgets from external sites do and is the recommended way. Or you can use a WP Super Cache filter to do the job but you can't use mod_rewrite mode caching. You have to switch to PHP or legacy caching.

385

386

WP Super Cache 1.4 introduced a cacheaction filter called wpsc_cachedata. The cached page to be displayed goes through this filter and allows modification of the page. If the page contains a placeholder tag the filter can be used to replace that tag with your dynamicly generated html.

387

The function that hooks on to the wpsc_cachedata filter should be put in a file in the plugins folder unless you use the late_init feature. An example plugin is included. Edit [dynamic-cache-test.php](http://svn.wp-plugins.org/wp-super-cache/trunk/plugins/dynamic-cache-test.php) and uncomment the code, and set the constant 'DYNAMIC_CACHE_TEST_TAG' to a random string that will not appear on your website. Change to PHP or legacy caching and activate dynamic caching on the Advanced Settings page and clear the cache. You should see the current server time in a html comment in the source code of your page. More details [in this post](http://ocaoimh.ie/2013/05/01/mfunc-in-wp-super-cache-1-4-and-beyond/).

387

388

To execute WordPress functions you must enable the 'Late init' feature on the advanced settings page.

388

389

389

= dynamic-cached-content example =

390

391

This code will include the file adverts.php and will execute the functions "print_sidebar_ad()" and "do_more_stuff()". Make sure there's no space before or after the PHP tags.

392

393

`<!--dynamic-cached-content--><?php

394

include_once( ABSPATH . '/scripts/adverts.php' );

395

print_sidebar_ad();

396

do_more_stuff();

397

?><!--

398

include_once( ABSPATH . '/scripts/adverts.php' );

399

print_sidebar_ad();

400

do_more_stuff();

401

--><!--/dynamic-cached-content-->`

402

403

= mfunc example =

404

405

To execute the function "function_name()":

406

407

`<!--mfunc function_name( 'parameter', 'another_parameter' ) -->

408

<?php function_name( 'parameter', 'another_parameter' ) ?>

409

<!--/mfunc-->`

410

411

= mclude example =

412

To include another file:

413

414

`<!--mclude file.php-->

415

<?php include_once( ABSPATH . 'file.php' ); ?>

416

<!--/mclude-->`

417

418

That will include file.php under the ABSPATH directory, which is the same as where your wp-config.php file is located.

This plugin caches entire pages but some plugins think they can run PHP code every time a page loads. To fix this, the plugin needs to use Javascript/AJAX methods or the dynamic-cached-content/mfunc/mclude code described in the previous answer to update or display dynamic information.

WordPress deletes the plugin folder when it updates a plugin. This is the same with WP Super Cache so any modified files in wp-super-cache/plugins/ will be deleted. You can define the variable $wp_cache_plugins_dir in wp-config.php or wp-content/wp-cache-config.php and point it at a directory outside of the wp-super-cache folder. The plugin will look there for it's plugins.