Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
WP Plugins
Redis Page Cache
Commits
0bc66a24
Commit
0bc66a24
authored
Dec 27, 2013
by
Hendrik Klemp
Browse files
Fix Typo
Fixed Typo
parent
50fded33
Changes
1
Hide whitespace changes
Inline
Side-by-side
index-wp-redis.php
View file @
0bc66a24
...
...
@@ -10,16 +10,13 @@ function getMicroTime($t)
}
$debug
=
fals
e
;
$debug
=
tru
e
;
$cache
=
false
;
$ip_of_your_website
=
'127.0.0.1'
;
$secret_string
=
'changeme'
;
if
(
!
defined
(
'WP_USE_THEMES'
))
{
define
(
'WP_USE_THEMES'
,
true
);
}
// so we don't confuse the cloudflare server
if
(
isset
(
$_SERVER
[
'HTTP_CF_CONNECTING_IP'
]))
{
...
...
@@ -56,6 +53,7 @@ try {
// This page is cached, lets display it
}
else
if
(
$redis
->
exists
(
$redis_key
))
{
$cache
=
true
;
$html_of_page
=
$redis
->
get
(
$redis_key
);
echo
$html_of_page
;
...
...
@@ -81,9 +79,9 @@ try {
// When a page displays after an "HTTP 404: Not Found" error occurs, do not cache
// When the search was used, do not cache
if
(
!
is_404
()
&&
!
is_search
())
{
if
(
(
!
is_404
()
)
and
(
!
is_search
())
)
{
if
(
$unlimited
)
{
$redis
->
set
ex
(
$redis_key
,
$html_of_page
);
$redis
->
set
(
$redis_key
,
$html_of_page
);
}
else
{
...
...
@@ -106,16 +104,16 @@ try {
require
(
'./wp-blog-header.php'
);
}
if
(
$_SERVER
[
'REMOTE_ADDR'
]
!=
$ip_of_your_website
)
{
// How long did it take to load the page? (CloudFlare may strip out comments)
$end
=
microtime
();
$time
=
(
@
getMicroTime
(
$end
)
-
@
getMicroTime
(
$start
));
echo
"<!-- Cache system by Benjamin Adams. Page generated in "
.
round
(
$time
,
5
)
.
" seconds. -->"
;
if
(
$debug
)
{
echo
"<!-- wp-redis-cache-seconds = "
.
$seconds_cache_redis
.
" -->"
;
echo
"<!-- wp-redis-cache-secret = "
.
$secret_string
.
"-->"
;
echo
"<!-- wp-redis-cache-ip = "
.
$ip_of_your_website
.
"-->"
;
echo
"<!-- wp-redis-cache-unlimited = "
.
$unlimited
.
"-->"
;
echo
"<!-- wp-redis-cache-debug = "
.
$debug
.
"-->"
;
}
$end
=
microtime
();
$time
=
(
@
getMicroTime
(
$end
)
-
@
getMicroTime
(
$start
));
if
(
$debug
)
{
echo
"<!-- Cache system by Benjamin Adams. Page generated in "
.
round
(
$time
,
5
)
.
" seconds. -->"
;
echo
"<!-- Site was cached = "
.
$cache
.
" -->"
;
echo
"<!-- wp-redis-cache-seconds = "
.
$seconds_cache_redis
.
" -->"
;
echo
"<!-- wp-redis-cache-secret = "
.
$secret_string
.
"-->"
;
echo
"<!-- wp-redis-cache-ip = "
.
$ip_of_your_website
.
"-->"
;
echo
"<!-- wp-redis-cache-unlimited = "
.
$unlimited
.
"-->"
;
echo
"<!-- wp-redis-cache-debug = "
.
$debug
.
"-->"
;
}
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