Skip to content

Instantly share code, notes, and snippets.

@mannieschumpert
Created October 14, 2014 15:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mannieschumpert/3f30e5ffa068a0525915 to your computer and use it in GitHub Desktop.
Save mannieschumpert/3f30e5ffa068a0525915 to your computer and use it in GitHub Desktop.
W3 Total Cache's approach to conditional loading is rather elegant.
<?php
/**
* Skip caching for some pages
*/
switch (true) {
case defined('DONOTCACHEPAGE'):
case defined('DOING_AJAX'):
case defined('DOING_CRON'):
case defined('APP_REQUEST'):
case defined('XMLRPC_REQUEST'):
case defined('WP_ADMIN'):
case (defined('SHORTINIT') && SHORTINIT):
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment