Title: Don&#039;t cache page UNLESS..
Last modified: August 24, 2016

---

# Don't cache page UNLESS..

 *  [AustinTBiggs](https://wordpress.org/support/users/austintbiggs/)
 * (@austintbiggs)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/dont-cache-page-unless/)
 * I have pages that aren’t completely loading (missing sidebar and footer), I’m
   trying to find a way to only create a cached version if the page completely loads.
   I’m just not sure what the best approach is; a few ideas..
 * – Disable page cache unless something in the footer is triggered?
    – Cache page,
   but remove if page doesn’t completely load? – Create a script that removes pages
   from the cache if they don’t have a footer? – Use JS to check the page once it
   finishes loading and see if there is a footer or a specific tag. If not use Ajax
   to call:
 * `Purge a single post / page by passing it's ID: if (function_exists('w3tc_pgcache_flush_post')){
   w3tc_pgcache_flush_post($post_id); }`
 * Any help would be appreciated!
    Thanks!
 * [https://wordpress.org/plugins/w3-total-cache/](https://wordpress.org/plugins/w3-total-cache/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [AustinTBiggs](https://wordpress.org/support/users/austintbiggs/)
 * (@austintbiggs)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/dont-cache-page-unless/#post-6012138)
 * I was able to solve my problem with a little bit of jquery. In case any needs
   this in the future, here’s the JS I put in the head of my pages.
 *     ```
       <script>
       	jQuery(window).load(function(){
       		if ( jQuery( 'footer' ).length ) {
   
       		} else {
       			$.get( '<?php echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>?w3tc_note=pgcache_purge_page' );
       		}
       	});
       </script>
       ```
   
 * I’m checking to see if ‘footer’ exists, if not it will purge the page from the
   cache to ensure that the next time the page is viewed a newly cached version 
   is available.

Viewing 1 replies (of 1 total)

The topic ‘Don't cache page UNLESS..’ is closed to new replies.

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

## Tags

 * [cache](https://wordpress.org/support/topic-tag/cache/)
 * [exclude](https://wordpress.org/support/topic-tag/exclude/)
 * [incomplete](https://wordpress.org/support/topic-tag/incomplete/)
 * [page-cache](https://wordpress.org/support/topic-tag/page-cache/)
 * [Purge](https://wordpress.org/support/topic-tag/purge/)
 * [purge cache](https://wordpress.org/support/topic-tag/purge-cache/)
 * [W3TC](https://wordpress.org/support/topic-tag/w3tc/)

 * 1 reply
 * 1 participant
 * Last reply from: [AustinTBiggs](https://wordpress.org/support/users/austintbiggs/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/dont-cache-page-unless/#post-6012138)
 * Status: not resolved