Skip to content

Commit

Permalink
Add support for preview detection; See: wpsharks/comet-cache#583
Browse files Browse the repository at this point in the history
  • Loading branch information
kristineds committed Oct 7, 2015
1 parent 5013c25 commit d449dca
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/includes/closures/Ac/NcDebugConsts.php
Expand Up @@ -166,6 +166,15 @@
*/
const NC_DEBUG_GET_REQUEST_QUERIES = 'nc_debug_get_request_queries';

/**
* No-cache because it's a preview.
*
* @since 15xxxx Adding support for preview detection.
*
* @type string A unique string identifier in the set of `NC_DEBUG_` constants.
*/
const NC_DEBUG_PREVIEW = 'nc_debug_preview';

/**
* No-cache because the current request excluded by its URI.
*
Expand Down
4 changes: 4 additions & 0 deletions src/includes/closures/Ac/NcDebugUtils.php
Expand Up @@ -140,6 +140,10 @@
$reason = __('because `$_GET` contains query string data. The current configuration says NOT to cache GET requests with a query string.', SLUG_TD);
break; // Break switch handler.

case NC_DEBUG_PREVIEW:
$reason = __('because `$_REQUEST` indicates this is simply a preview of something to come.', SLUG_TD);
break; // Break switch handler.

case NC_DEBUG_EXCLUDED_URIS:
$reason = __('because `$_SERVER[\'REQUEST_URI\']` matches a configured URI Exclusion Pattern on this installation.', SLUG_TD);
break; // Break switch handler.
Expand Down
3 changes: 3 additions & 0 deletions src/includes/closures/Ac/ObUtils.php
Expand Up @@ -150,6 +150,9 @@
if (!ZENCACHE_GET_REQUESTS && $self->requestContainsUncacheableQueryVars()) {
return $self->maybeSetDebugInfo(NC_DEBUG_GET_REQUEST_QUERIES);
}
if (!empty($_REQUEST['preview'])) {
return $self->maybeSetDebugInfo(NC_DEBUG_PREVIEW);
}
if (ZENCACHE_EXCLUDE_URIS && preg_match(ZENCACHE_EXCLUDE_URIS, $_SERVER['REQUEST_URI'])) {
return $self->maybeSetDebugInfo(NC_DEBUG_EXCLUDED_URIS);
}
Expand Down

0 comments on commit d449dca

Please sign in to comment.