• I see the “DO NOT CACHE PAGE”secret code.

    I built a cache to serve my sidebar content to a “quick-connect app” that I created for mobile clients.

    You can see the app at http://spartabands.org/app

    You will need to shrink down the app to allow for the javascript to redesign the layout and function to a smartphone.

    I am getting the following message now under my “Coming Events”
    panel in the smartphone version of the page.

    “Warning: Cannot modify header information – headers already sent by (output started at /home/spartaba/public_html/app/index.php:5) in /home/spartaba/public_html/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 89”

    I need to understand where I need to install and how to execute the do not cache this page in regards to the error.

    Many thanks for your time.

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • add this at the top of your app/index.php:

    define( 'DONOTCACHEPAGE', 1 );

    That’s all you need to stop caching.

    Thread Starter weboperations

    (@weboperations)

    so you are saying
    <?php
    define( 'DONOTCACHEPAGE', 1 );
    ?>
    <!DOCTYPE HTML>

    or am I missing something?

    Thread Starter weboperations

    (@weboperations)

    it still has the error.

    Thread Starter weboperations

    (@weboperations)

    The content of the panel comes from

    <?php
    include “../wp-load.php”;
    $myCachedFile = “../wp-content/themes/cyberchimpspro/cache/cache-sidebar.txt”;
    if(file_exists($myCachedFile))
    include_once($myCachedFile);
    else
    echo “Cache doesn’t exist.”;
    ?>

    Define DONOTCACHEHOME before your load wp-load.php and see if that helps?

    Are you sure there’s not an empty space before the opening PHP tag?

    Thread Starter weboperations

    (@weboperations)

    Positive-

    <?php
    define( ‘DONOTCACHEPAGE’, 1 );
    ?>
    <!DOCTYPE HTML>
    <html>
    <head>

    from line 1.

    I am wondering if it is a functional issue.
    I use the following code in the function.php file to cache the sidebar to a text file that is refreshed by a timed expire. Perhaps I need to rename a variable?

    // add sidebar function

    function cache($task, $cacheFile, $cacheTime = 600){
    global $cache;

    // Configure files and directories:
    $cacheDir = TEMPLATEPATH.”/cache”;
    $cacheFileName = $cacheDir.”/cache-$cacheFile.txt”;
    $cacheLogFile = $cacheDir.”/cache-log.txt”;

    // Make cache directory if it doesn’t exist
    if(!is_dir($cacheDir)) mkdir($cacheDir, 0755);

    // Make a log of the cache files with their current status
    if(file_exists($cacheLogFile))
    $cacheLog = unserialize(file_get_contents($cacheLogFile));
    else
    $cacheLog = array();

    if($task == ‘start’){
    // If cache exists, is less than 6 hours old and is not in deletion queue, keep it – otherwise rebuild cache
    if(file_exists($cacheFileName) && (time() – filemtime($cacheFileName)) < $cacheTime && $cacheLog[$cacheFile] == 1){
    $cache = false;
    } else {
    $cache = true;
    ob_start();
    }
    }elseif($task == ‘end’ && $cache){
    // If caching, save file contents and update log
    file_put_contents($cacheFileName,ob_get_contents());
    ob_end_flush();
    $cacheLog[$cacheFile] = 1;
    file_put_contents($cacheLogFile,serialize($cacheLog));
    }elseif($task == ‘purge’){
    // Set cache to delete and update log
    $cacheLog[$cacheFile] = 0;
    file_put_contents($cacheLogFile,serialize($cacheLog));
    }

    }
    function cache_purge(){
    $cacheDir = TEMPLATEPATH.”/cache”;
    $cacheLogFile = $cacheDir.”/cache-log.txt”;
    if(file_exists($cacheLogFile))
    $cacheLog = unserialize(file_get_contents($cacheLogFile));
    else
    $cacheLog = array();
    foreach($cacheLog as $key=>$value)
    $cacheLog[$key] = 0;
    file_put_contents($cacheLogFile,serialize($cacheLog));
    add_action(‘switch_theme’,’cache_purge’, 10);
    add_action(‘publish_post’,’cache_purge’, 10);
    add_filter(‘widget_update_callback’,’cache_purge’, 10);
    }

    This is the file that the cache is pulled from called sidebar-right.php

    <?php
    cache(‘start’, ‘sidebar’);
    /**
    * Sidebar Right Template
    *
    * Please do not edit this file. This file is part of the Cyber Chimps Framework and all modifications
    * should be made in a child theme.
    *
    * @category CyberChimps Framework
    * @package Framework
    * @since 1.0
    * @author CyberChimps
    * @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
    * @link http://www.cyberchimps.com/
    */
    ?>

    <div id=”secondary” <?php cyberchimps_filter_sidebar_right_class(); ?>>

    <?php do_action( ‘cyberchimps_before_sidebar’ ); ?>

    <div id=”sidebar”>
    <?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar( ‘sidebar-right’ ) ) : ?>

    <div class=”widget-container”>
    <h3 class=”widget-title”><?php _e(‘Pages’, ‘cyberchimps’ ); ?></h3>

      <?php wp_list_pages(‘title_li=’ ); ?>

    </div>

    <div class=”widget-container”>
    <h3 class=”widget-title”><?php _e( ‘Archives’, ‘cyberchimps’ ); ?></h3>

      <?php wp_get_archives(‘type=monthly’); ?>

    </div>

    <div class=”widget-container”>
    <h3 class=”widget-title”><?php _e(‘Categories’, ‘cyberchimps’ ); ?></h3>

      <?php wp_list_categories(‘show_count=1&title_li=’); ?>

    </div>

    <div class=”widget-container”>
    <h3 class=”widget-title”><?php _e(‘WordPress’, ‘cyberchimps’ ); ?></h3>

    </div>

    <div class=”widget-container”>
    <h3 class=”widget-title”><?php _e(‘Subscribe’, ‘cyberchimps’ ); ?></h3>

    </div>

    <?php endif; ?>
    </div><!– #sidebar –>

    <?php do_action( ‘cyberchimps_after_sidebar’ ); ?>

    </div><!– #secondary .widget-area .span3 –>
    <?php cache(‘end’, ‘sidebar’); ?>

    It simply creates a text cache that I use to clone the calendar into the quick access app that I created in bootstrap 3.0 .

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Do not cache elements’ is closed to new replies.