Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
R
Redis Page Cache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
WP Plugins
Redis Page Cache
Commits
bc06c918
Commit
bc06c918
authored
Feb 25, 2014
by
Erick Hitter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coding Standards: variable naming
parent
3405ef4f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
index-wp-redis.php
index-wp-redis.php
+15
-15
No files found.
index-wp-redis.php
View file @
bc06c918
...
...
@@ -16,11 +16,11 @@ function request_has_secret( $secret ) {
return
false
!==
strpos
(
$_SERVER
[
'REQUEST_URI'
],
"refresh=${secret}"
);
}
function
is_remote_page_load
(
$current
Url
,
$websiteI
p
)
{
function
is_remote_page_load
(
$current
_url
,
$server_i
p
)
{
return
(
isset
(
$_SERVER
[
'HTTP_REFERER'
]
)
&&
$_SERVER
[
'HTTP_REFERER'
]
==
$current
U
rl
&&
$_SERVER
[
'HTTP_REFERER'
]
==
$current
_u
rl
&&
$_SERVER
[
'REQUEST_URI'
]
!=
'/'
&&
$_SERVER
[
'REMOTE_ADDR'
]
!=
$
websiteI
p
);
&&
$_SERVER
[
'REMOTE_ADDR'
]
!=
$
server_i
p
);
}
function
handle_cdn_remote_addressing
()
{
...
...
@@ -31,15 +31,15 @@ function handle_cdn_remote_addressing() {
}
function
get_clean_url
(
$secret
)
{
$replace
K
eys
=
array
(
"?refresh=${secret}"
,
"&refresh=${secret}"
);
$replace
_k
eys
=
array
(
"?refresh=${secret}"
,
"&refresh=${secret}"
);
$url
=
"http://${_SERVER['HTTP_HOST']}${_SERVER['REQUEST_URI']}"
;
$current_url
=
str_replace
(
$replace
K
eys
,
''
,
$url
);
$current_url
=
str_replace
(
$replace
_k
eys
,
''
,
$url
);
return
$current_url
;
}
$debug
=
true
;
$cache
=
true
;
$
websiteI
p
=
'127.0.0.1'
;
$
server_i
p
=
'127.0.0.1'
;
$reddis_server
=
'127.0.0.1'
;
$secret_string
=
'changeme'
;
$current_url
=
get_clean_url
(
$secret_string
);
...
...
@@ -73,7 +73,7 @@ try {
}
//Either manual refresh cache by adding ?refresh=secret_string after the URL or somebody posting a comment
if
(
refresh_has_secret
(
$secret_string
)
||
request_has_secret
(
$secret_string
)
||
is_remote_page_load
(
$current_url
,
$
websiteI
p
)
)
{
if
(
refresh_has_secret
(
$secret_string
)
||
request_has_secret
(
$secret_string
)
||
is_remote_page_load
(
$current_url
,
$
server_i
p
)
)
{
if
(
$debug
)
{
echo
"<!-- manual refresh was required -->
\n
"
;
}
...
...
@@ -82,7 +82,7 @@ try {
require
(
'./wp-blog-header.php'
);
$unlimited
=
get_option
(
'wp-redis-cache-debug'
,
false
);
$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
...
...
@@ -93,19 +93,19 @@ try {
$cache
=
true
;
$html_of_page
=
$redis
->
get
(
$redis_key
);
$html_of_page
=
$redis
->
get
(
$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'
]
!=
$
websiteI
p
&&
false
===
strstr
(
$current_url
,
'preview=true'
)
)
{
}
elseif
(
$_SERVER
[
'REMOTE_ADDR'
]
!=
$
server_i
p
&&
false
===
strstr
(
$current_url
,
'preview=true'
)
)
{
if
(
$debug
)
{
echo
"<!-- displaying page without cache -->
\n
"
;
}
$isPOST
=
(
int
)
'POST'
===
$_SERVER
[
'REQUEST_METHOD'
];
$is_post
=
(
int
)
'POST'
===
$_SERVER
[
'REQUEST_METHOD'
];
$logged_in
=
preg_match
(
"/wordpress_logged_in/"
,
var_export
(
$_COOKIE
,
true
)
);
$loggedIn
=
preg_match
(
"/wordpress_logged_in/"
,
var_export
(
$_COOKIE
,
true
)
);
if
(
!
$isPOST
&&
!
$loggedIn
)
{
if
(
!
$is_post
&&
!
$logged_in
)
{
ob_start
();
require
(
'./wp-blog-header.php'
);
$html_of_page
=
ob_get_contents
();
...
...
@@ -128,7 +128,7 @@ try {
}
else
{
//either the user is logged in, or is posting a comment, show them uncached
require
(
'./wp-blog-header.php'
);
}
}
elseif
(
$_SERVER
[
'REMOTE_ADDR'
]
!=
$
websiteI
p
&&
true
===
strstr
(
$current_url
,
'preview=true'
)
)
{
}
elseif
(
$_SERVER
[
'REMOTE_ADDR'
]
!=
$
server_i
p
&&
true
===
strstr
(
$current_url
,
'preview=true'
)
)
{
require
(
'./wp-blog-header.php'
);
}
// else { // This is what your server should get if no cache exists //deprecated, as the ob_start() is cleaner
...
...
@@ -148,7 +148,7 @@ if ( $debug ) {
echo
"<!-- wp-redis-cache-seconds = "
.
$seconds_cache_redis
.
" -->
\n
"
;
}
echo
"<!-- wp-redis-cache-secret = "
.
$secret_string
.
"-->
\n
"
;
echo
"<!-- wp-redis-cache-ip = "
.
$
websiteI
p
.
"-->
\n
"
;
echo
"<!-- wp-redis-cache-ip = "
.
$
server_i
p
.
"-->
\n
"
;
if
(
isset
(
$unlimited
)
)
{
echo
"<!-- wp-redis-cache-unlimited = "
.
$unlimited
.
"-->
\n
"
;
}
...
...
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