Title: Do not cache elements
Last modified: August 21, 2016

---

# Do not cache elements

 *  [weboperations](https://wordpress.org/support/users/weboperations/)
 * (@weboperations)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/do-not-cache-elements/)
 * 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](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/](http://wordpress.org/plugins/wp-super-cache/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/do-not-cache-elements/#post-4251999)
 * add this at the top of your app/index.php:
 * `define( 'DONOTCACHEPAGE', 1 );`
 * That’s all you need to stop caching.
 *  Thread Starter [weboperations](https://wordpress.org/support/users/weboperations/)
 * (@weboperations)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/do-not-cache-elements/#post-4252011)
 * so you are saying
    <?php define( 'DONOTCACHEPAGE', 1 ); ?> <!DOCTYPE HTML>
 * or am I missing something?
 *  Thread Starter [weboperations](https://wordpress.org/support/users/weboperations/)
 * (@weboperations)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/do-not-cache-elements/#post-4252012)
 * it still has the error.
 *  Thread Starter [weboperations](https://wordpress.org/support/users/weboperations/)
 * (@weboperations)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/do-not-cache-elements/#post-4252017)
 * 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.”; ?>
 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/do-not-cache-elements/#post-4252108)
 * 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](https://wordpress.org/support/users/weboperations/)
 * (@weboperations)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/do-not-cache-elements/#post-4252113)
 * 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](https://wordpress.org/support/users/category/)
   CyberChimps Framework * [@package](https://wordpress.org/support/users/package/)
   Framework * [@since](https://wordpress.org/support/users/since/) 1.0 * [@author](https://wordpress.org/support/users/author/)
   CyberChimps * [@license](https://wordpress.org/support/users/license/) [http://www.opensource.org/licenses/gpl-license.php](http://www.opensource.org/licenses/gpl-license.php)
   GPL v2.0 (or later) * [@link](https://wordpress.org/support/users/link/) [http://www.cyberchimps.com/](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>
    -  <?php wp_register(); ?>
    - <?php wp_loginout(); ?>
    - 
    -  <?php wp_meta(); ?>
 *  </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.

 * ![](https://ps.w.org/wp-super-cache/assets/icon-256x256.png?rev=3506220)
 * [WP Super Cache](https://wordpress.org/plugins/wp-super-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-super-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-super-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-super-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-super-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-super-cache/reviews/)

## Tags

 * [Custom Coding](https://wordpress.org/support/topic-tag/custom-coding/)

 * 6 replies
 * 2 participants
 * Last reply from: [weboperations](https://wordpress.org/support/users/weboperations/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/do-not-cache-elements/#post-4252113)
 * Status: not resolved