Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Redis Page Cache
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
WP Plugins
Redis Page Cache
Commits
6aec566c
Commit
6aec566c
authored
11 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Namespace all functions
parent
2e52d79d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
index-wp-redis.php
+10
-10
10 additions, 10 deletions
index-wp-redis.php
with
10 additions
and
10 deletions
index-wp-redis.php
+
10
−
10
View file @
6aec566c
...
@@ -28,47 +28,47 @@ function wp_redis_cache_exception_handler( $exception ) {
...
@@ -28,47 +28,47 @@ function wp_redis_cache_exception_handler( $exception ) {
/**
/**
* DO NOT EDIT BELOW THIS LINE!
* DO NOT EDIT BELOW THIS LINE!
*/
*/
$GLOBALS
[
'wp_redis_cache_config'
][
'current_url'
]
=
get_clean_url
(
$GLOBALS
[
'wp_redis_cache_config'
][
'secret_string'
]
);
$GLOBALS
[
'wp_redis_cache_config'
][
'current_url'
]
=
wp_redis_cache_
get_clean_url
(
$GLOBALS
[
'wp_redis_cache_config'
][
'secret_string'
]
);
$GLOBALS
[
'wp_redis_cache_config'
][
'redis_key'
]
=
md5
(
$GLOBALS
[
'wp_redis_cache_config'
][
'current_url'
]
);
$GLOBALS
[
'wp_redis_cache_config'
][
'redis_key'
]
=
md5
(
$GLOBALS
[
'wp_redis_cache_config'
][
'current_url'
]
);
// Start the timer so we can track the page load time
// Start the timer so we can track the page load time
$start
=
microtime
();
$start
=
microtime
();
function
get_micro_time
(
$time
)
{
function
wp_redis_cache_
get_micro_time
(
$time
)
{
list
(
$usec
,
$sec
)
=
explode
(
" "
,
$time
);
list
(
$usec
,
$sec
)
=
explode
(
" "
,
$time
);
return
(
(
float
)
$usec
+
(
float
)
$sec
);
return
(
(
float
)
$usec
+
(
float
)
$sec
);
}
}
function
refresh_has_secret
(
$secret
)
{
function
wp_redis_cache_
refresh_has_secret
(
$secret
)
{
return
isset
(
$_GET
[
'refresh'
]
)
&&
$secret
==
$_GET
[
'refresh'
];
return
isset
(
$_GET
[
'refresh'
]
)
&&
$secret
==
$_GET
[
'refresh'
];
}
}
function
request_has_secret
(
$secret
)
{
function
wp_redis_cache_
request_has_secret
(
$secret
)
{
return
false
!==
strpos
(
$_SERVER
[
'REQUEST_URI'
],
"refresh=${secret}"
);
return
false
!==
strpos
(
$_SERVER
[
'REQUEST_URI'
],
"refresh=${secret}"
);
}
}
function
is_remote_page_load
(
$current_url
,
$server_ip
)
{
function
wp_redis_cache_
is_remote_page_load
(
$current_url
,
$server_ip
)
{
return
(
isset
(
$_SERVER
[
'HTTP_REFERER'
]
)
return
(
isset
(
$_SERVER
[
'HTTP_REFERER'
]
)
&&
$_SERVER
[
'HTTP_REFERER'
]
==
$current_url
&&
$_SERVER
[
'HTTP_REFERER'
]
==
$current_url
&&
$_SERVER
[
'REQUEST_URI'
]
!=
'/'
&&
$_SERVER
[
'REQUEST_URI'
]
!=
'/'
&&
$_SERVER
[
'REMOTE_ADDR'
]
!=
$server_ip
);
&&
$_SERVER
[
'REMOTE_ADDR'
]
!=
$server_ip
);
}
}
function
handle_cdn_remote_addressing
()
{
function
wp_redis_cache_
handle_cdn_remote_addressing
()
{
// so we don't confuse the cloudflare server
// so we don't confuse the cloudflare server
if
(
isset
(
$_SERVER
[
'HTTP_CF_CONNECTING_IP'
]
)
)
{
if
(
isset
(
$_SERVER
[
'HTTP_CF_CONNECTING_IP'
]
)
)
{
$_SERVER
[
'REMOTE_ADDR'
]
=
$_SERVER
[
'HTTP_CF_CONNECTING_IP'
];
$_SERVER
[
'REMOTE_ADDR'
]
=
$_SERVER
[
'HTTP_CF_CONNECTING_IP'
];
}
}
}
}
function
get_clean_url
(
$secret
)
{
function
wp_redis_cache_
get_clean_url
(
$secret
)
{
$replace_keys
=
array
(
"?refresh=${secret}"
,
"&refresh=${secret}"
);
$replace_keys
=
array
(
"?refresh=${secret}"
,
"&refresh=${secret}"
);
$url
=
"http://${_SERVER['HTTP_HOST']}${_SERVER['REQUEST_URI']}"
;
$url
=
"http://${_SERVER['HTTP_HOST']}${_SERVER['REQUEST_URI']}"
;
$current_url
=
str_replace
(
$replace_keys
,
''
,
$url
);
$current_url
=
str_replace
(
$replace_keys
,
''
,
$url
);
return
$current_url
;
return
$current_url
;
}
}
handle_cdn_remote_addressing
();
wp_redis_cache_
handle_cdn_remote_addressing
();
if
(
!
defined
(
'WP_USE_THEMES'
)
)
{
if
(
!
defined
(
'WP_USE_THEMES'
)
)
{
define
(
'WP_USE_THEMES'
,
true
);
define
(
'WP_USE_THEMES'
,
true
);
...
@@ -100,7 +100,7 @@ try {
...
@@ -100,7 +100,7 @@ try {
}
}
//Either manual refresh cache by adding ?refresh=secret_string after the URL or somebody posting a comment
//Either manual refresh cache by adding ?refresh=secret_string after the URL or somebody posting a comment
if
(
refresh_has_secret
(
$GLOBALS
[
'wp_redis_cache_config'
][
'secret_string'
]
)
||
request_has_secret
(
$GLOBALS
[
'wp_redis_cache_config'
][
'secret_string'
]
)
||
is_remote_page_load
(
$GLOBALS
[
'wp_redis_cache_config'
][
'current_url'
],
$GLOBALS
[
'wp_redis_cache_config'
][
'server_ip'
]
)
)
{
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'
]
)
{
if
(
$GLOBALS
[
'wp_redis_cache_config'
][
'debug'
]
)
{
echo
"<!-- manual refresh was required -->
\n
"
;
echo
"<!-- manual refresh was required -->
\n
"
;
}
}
...
@@ -181,7 +181,7 @@ try {
...
@@ -181,7 +181,7 @@ try {
}
}
$end
=
microtime
();
$end
=
microtime
();
$time
=
@
get_micro_time
(
$end
)
-
@
get_micro_time
(
$start
);
$time
=
@
wp_redis_cache_
get_micro_time
(
$end
)
-
@
wp_redis_cache_
get_micro_time
(
$start
);
if
(
$GLOBALS
[
'wp_redis_cache_config'
][
'debug'
]
)
{
if
(
$GLOBALS
[
'wp_redis_cache_config'
][
'debug'
]
)
{
echo
"<!-- Cache system by Benjamin Adams. Page generated in "
.
round
(
$time
,
5
)
.
" seconds. -->
\n
"
;
echo
"<!-- Cache system by Benjamin Adams. Page generated in "
.
round
(
$time
,
5
)
.
" seconds. -->
\n
"
;
echo
"<!-- Site was cached = "
.
$GLOBALS
[
'wp_redis_cache_config'
][
'cache'
]
.
" -->
\n
"
;
echo
"<!-- Site was cached = "
.
$GLOBALS
[
'wp_redis_cache_config'
][
'cache'
]
.
" -->
\n
"
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment