header('Vary: Cookie', false); // Things that define a unique page. if (isset($_SERVER['QUERY_STRING'])) { parse_str($_SERVER['QUERY_STRING'], $batcache->query); } $batcache->keys = array('host' => $_SERVER['HTTP_HOST'], 'method' => $_SERVER['REQUEST_METHOD'], 'path' => ($batcache->pos = strpos($_SERVER['REQUEST_URI'], '?')) ? substr($_SERVER['REQUEST_URI'], 0, $batcache->pos) : $_SERVER['REQUEST_URI'], 'query' => $batcache->query, 'extra' => $batcache->unique); if ($batcache->is_ssl()) { $batcache->keys['ssl'] = true; } // Recreate the permalink from the URL $batcache->permalink = 'http://' . $batcache->keys['host'] . $batcache->keys['path'] . (isset($batcache->keys['query']['p']) ? "?p=" . $batcache->keys['query']['p'] : ''); $batcache->url_key = md5($batcache->permalink); $batcache->url_version = (int) wp_cache_get("{$batcache->url_key}_version", $batcache->group); $batcache->configure_groups(); $batcache->do_variants(); $batcache->generate_keys(); // Get the batcache $batcache->cache = wp_cache_get($batcache->key, $batcache->group); // Are we only caching frequently-requested pages? if ($batcache->seconds < 1 || $batcache->times < 2) { $batcache->do = true; } else { // No batcache item found, or ready to sample traffic again at the end of the batcache life? if (!is_array($batcache->cache) || time() >= $batcache->cache['time'] + $batcache->max_age - $batcache->seconds) { wp_cache_add($batcache->req_key, 0, $batcache->group); $batcache->requests = wp_cache_incr($batcache->req_key, 1, $batcache->group); if ($batcache->requests >= $batcache->times) { $batcache->do = true; } else { $batcache->do = false; }