Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
WP Plugins
Redis Page Cache
Commits
1e5b1a79
Commit
1e5b1a79
authored
Feb 26, 2014
by
Erick Hitter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct bug introduced in
35d01c95
that resulted in caches being set but never shown to the user
parent
7e5a41c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
index-wp-redis.php
index-wp-redis.php
+15
-14
No files found.
index-wp-redis.php
View file @
1e5b1a79
...
...
@@ -171,6 +171,10 @@ try {
// Establish connection with Redis server
$redis
=
wp_redis_cache_connect_redis
();
// Relevant details on the current request
$is_post
=
(
bool
)
'POST'
===
$_SERVER
[
'REQUEST_METHOD'
];
$logged_in
=
(
bool
)
preg_match
(
"#(wordpress_(logged|sec)|comment_author)#"
,
var_export
(
$_COOKIE
,
true
)
);
//Either manual refresh cache by adding ?refresh=secret_string after the URL or somebody posting a comment
if
(
wp_redis_cache_refresh_has_secret
(
$GLOBALS
[
'wp_redis_cache_config'
][
'secret_string'
]
)
||
wp_redis_cache_request_has_secret
(
$GLOBALS
[
'wp_redis_cache_config'
][
'secret_string'
]
)
||
wp_redis_cache_is_remote_page_load
(
$GLOBALS
[
'wp_redis_cache_config'
][
'current_url'
],
$GLOBALS
[
'wp_redis_cache_config'
][
'server_ip'
]
)
)
{
if
(
$GLOBALS
[
'wp_redis_cache_config'
][
'debug'
]
)
{
...
...
@@ -180,15 +184,23 @@ try {
$redis
->
del
(
$GLOBALS
[
'wp_redis_cache_config'
][
'redis_key'
]
);
require
dirname
(
__FILE__
)
.
'/wp-blog-header.php'
;
// This page is cached, lets display it
}
elseif
(
!
$is_post
&&
!
$logged_in
&&
$redis
->
exists
(
$GLOBALS
[
'wp_redis_cache_config'
][
'redis_key'
]
)
)
{
if
(
$GLOBALS
[
'wp_redis_cache_config'
][
'debug'
]
)
{
echo
"<!-- serving page from cache: key: "
.
$GLOBALS
[
'wp_redis_cache_config'
][
'redis_key'
]
.
" -->
\n
"
;
}
$GLOBALS
[
'wp_redis_cache_config'
][
'cached'
]
=
true
;
$html_of_page
=
trim
(
$redis
->
get
(
$GLOBALS
[
'wp_redis_cache_config'
][
'redis_key'
]
)
);
echo
$html_of_page
;
// If the cache does not exist lets display the user the normal page without cache, and then fetch a new cache page
}
elseif
(
$_SERVER
[
'REMOTE_ADDR'
]
!=
$GLOBALS
[
'wp_redis_cache_config'
][
'server_ip'
]
&&
false
===
strstr
(
$GLOBALS
[
'wp_redis_cache_config'
][
'current_url'
],
'preview=true'
)
)
{
if
(
$GLOBALS
[
'wp_redis_cache_config'
][
'debug'
]
)
{
echo
"<!-- displaying page without cache -->
\n
"
;
}
$is_post
=
(
bool
)
'POST'
===
$_SERVER
[
'REQUEST_METHOD'
];
$logged_in
=
(
bool
)
preg_match
(
"#(wordpress_(logged|sec)|comment_author)#"
,
var_export
(
$_COOKIE
,
true
)
);
if
(
$GLOBALS
[
'wp_redis_cache_config'
][
'debug'
]
)
{
echo
"<!-- POST request: . "
.
(
$is_post
?
'yes'
:
'no'
)
.
"-->
\n
"
;
echo
"<!-- Logged in: . "
.
(
$logged_in
?
'yes'
:
'no'
)
.
"-->
\n
"
;
...
...
@@ -233,17 +245,6 @@ try {
}
}
elseif
(
$_SERVER
[
'REMOTE_ADDR'
]
!=
$GLOBALS
[
'wp_redis_cache_config'
][
'server_ip'
]
&&
true
===
strstr
(
$GLOBALS
[
'wp_redis_cache_config'
][
'current_url'
],
'preview=true'
)
)
{
require
dirname
(
__FILE__
)
.
'/wp-blog-header.php'
;
// This page is cached, lets display it
}
elseif
(
$redis
->
exists
(
$GLOBALS
[
'wp_redis_cache_config'
][
'redis_key'
]
)
)
{
if
(
$GLOBALS
[
'wp_redis_cache_config'
][
'debug'
]
)
{
echo
"<!-- serving page from cache: key: "
.
$GLOBALS
[
'wp_redis_cache_config'
][
'redis_key'
]
.
" -->
\n
"
;
}
$GLOBALS
[
'wp_redis_cache_config'
][
'cached'
]
=
true
;
$html_of_page
=
trim
(
$redis
->
get
(
$GLOBALS
[
'wp_redis_cache_config'
][
'redis_key'
]
)
);
echo
$html_of_page
;
}
else
{
require
dirname
(
__FILE__
)
.
'/wp-blog-header.php'
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment