Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When user is logged in no cache is made. #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions index-wp-redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function getCleanUrl($secret) {
$current_url = getCleanUrl($secret_string);
// used to prefix ssl cached pages
$isSSL = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) ? "ssl_" : "";
$isLoggedIn = preg_match("/wordpress_logged_in/", var_export($_COOKIE, true));
$redis_key = $isSSL.md5($current_url);

handleCDNRemoteAddressing();
Expand Down Expand Up @@ -104,7 +105,7 @@ function getCleanUrl($secret) {
$unlimited = get_option('wp-redis-cache-debug',false);
$seconds_cache_redis = get_option('wp-redis-cache-seconds',43200);
// This page is cached, lets display it
} else if ($redis->exists($redis_key)) {
} else if ($redis->exists($redis_key) && !$isLoggedIn) {
if ($debug) {
echo "<!-- serving page from cache: key: $redis_key -->\n";
}
Expand All @@ -120,8 +121,7 @@ function getCleanUrl($secret) {

$isPOST = ($_SERVER['REQUEST_METHOD'] === 'POST') ? 1 : 0;

$loggedIn = preg_match("/wordpress_logged_in/", var_export($_COOKIE, true));
if (!$isPOST && !$loggedIn) {
if (!$isPOST && !$isLoggedIn) {
ob_start();
$level = ob_get_level();
require( $wp_blog_header_path );
Expand Down Expand Up @@ -167,10 +167,11 @@ function getCleanUrl($secret) {
if (isset($seconds_cache_redis)) {
echo "<!-- wp-redis-cache-seconds = " . $seconds_cache_redis . " -->\n";
}
echo "<!-- is logged in? " . $isLoggedIn . "-->\n";
echo "<!-- wp-redis-cache-secret = " . $secret_string . "-->\n";
echo "<!-- wp-redis-cache-ip = " . $websiteIp . "-->\n";
if (isset($unlimited)) {
echo "<!-- wp-redis-cache-unlimited = " . $unlimited . "-->\n";
}
echo "<!-- wp-redis-cache-debug = " . $debug . "-->\n";
}
}