Is there any mean to exclude a *.php file to WP Super Cache?
I've in my single.php page an include news.php, the file news.php contains ten links to my last articles.

So I want to cache single.php but to exclude news.php that is included in single.php.

It is possible? How can I do that?


2 Answers 2


Rather than incorporating dynamic content into cached pages, you are better off using AJAX to pull dynamic content onto those pages in the browser.

In your news.php file, simply have an empty element that will contain the content. Better still, have it contain an AJAX spinner that indicates that content is coming.

<div id="late-load-news">
    <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/ajax-loader.gif" />

Then use jQuery to load your news content -- this code goes in your theme's functions.php:

* AJAX handler to output an HTML fragment for news
function wpse_70813_news() {
    // stop browser from caching output
    header('Pragma: public');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');

    //...output your news content here...


add_action('wp_ajax_late-load-news', 'wpse_70813_news');
add_action('wp_ajax_nopriv_late-load-news', 'wpse_70813_news');

* enqueue jQuery
add_action('wp_enqueue_script', function() {

* add footer script to load news
add_action('wp_print_footer_script', function() {

        type : "GET",
        url : "<?php echo admin_url('admin-ajax.php'); ?>",
        dataType : "html",
        data : { action: "late-load-news" },
        success : function(content) {


That will load the content every time a visitor navigates to a new page. If your news content doesn't change much, I recommend you make use of sessionStorage to cache the news content in the browser for the duration of the visit. If you want to limit how long that cache lasts, see Session storage with expiry time.


Follow the steps below to prevent caching of the news.php file:

  1. Visit the WP Super Cache settings page in your WordPress administration dashboard (Settings > WP Super Cache).

  2. Visit the 'Advanced' tab along the top of that page

  3. Scroll down to the Accepted Filenames & Rejected URIs heading

  4. Look for the box with the description of:

    Add here those filenames that can be cached, even if they match one of the rejected substring specified above.

  5. Enter news.php on a new line in the textbox below the description

  6. Click Save Files »

  • Thank you! I've tried this, doesn't change :( my list isn't dynamically generated :/
    – ranell
    Commented Oct 29, 2012 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.