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
2fc23bd0
Commit
2fc23bd0
authored
11 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
WP Coding Standards: function naming
parent
449e7411
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 @
2fc23bd0
...
@@ -3,34 +3,34 @@
...
@@ -3,34 +3,34 @@
// 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
M
icro
T
ime
(
$time
)
{
function
get
_m
icro
_t
ime
(
$time
)
{
list
(
$usec
,
$sec
)
=
explode
(
" "
,
$time
);
list
(
$usec
,
$sec
)
=
explode
(
" "
,
$time
);
return
((
float
)
$usec
+
(
float
)
$sec
);
return
((
float
)
$usec
+
(
float
)
$sec
);
}
}
function
refresh
HasS
ecret
(
$secret
)
{
function
refresh
_has_s
ecret
(
$secret
)
{
return
isset
(
$_GET
[
'refresh'
])
&&
$_GET
[
'refresh'
]
==
$secret
;
return
isset
(
$_GET
[
'refresh'
])
&&
$_GET
[
'refresh'
]
==
$secret
;
}
}
function
request
HasS
ecret
(
$secret
)
{
function
request
_has_s
ecret
(
$secret
)
{
return
strpos
(
$_SERVER
[
'REQUEST_URI'
],
"refresh=${secret}"
)
!==
false
;
return
strpos
(
$_SERVER
[
'REQUEST_URI'
],
"refresh=${secret}"
)
!==
false
;
}
}
function
is
R
emote
P
age
L
oad
(
$currentUrl
,
$websiteIp
)
{
function
is
_r
emote
_p
age
_l
oad
(
$currentUrl
,
$websiteIp
)
{
return
(
isset
(
$_SERVER
[
'HTTP_REFERER'
])
return
(
isset
(
$_SERVER
[
'HTTP_REFERER'
])
&&
$_SERVER
[
'HTTP_REFERER'
]
==
$currentUrl
&&
$_SERVER
[
'HTTP_REFERER'
]
==
$currentUrl
&&
$_SERVER
[
'REQUEST_URI'
]
!=
'/'
&&
$_SERVER
[
'REQUEST_URI'
]
!=
'/'
&&
$_SERVER
[
'REMOTE_ADDR'
]
!=
$websiteIp
);
&&
$_SERVER
[
'REMOTE_ADDR'
]
!=
$websiteIp
);
}
}
function
handle
CDNR
emote
A
ddressing
()
{
function
handle
_cdn_r
emote
_a
ddressing
()
{
// 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
C
lean
U
rl
(
$secret
)
{
function
get
_c
lean
_u
rl
(
$secret
)
{
$replaceKeys
=
array
(
"?refresh=${secret}"
,
"&refresh=${secret}"
);
$replaceKeys
=
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
(
$replaceKeys
,
''
,
$url
);
$current_url
=
str_replace
(
$replaceKeys
,
''
,
$url
);
...
@@ -42,10 +42,10 @@ $cache = true;
...
@@ -42,10 +42,10 @@ $cache = true;
$websiteIp
=
'127.0.0.1'
;
$websiteIp
=
'127.0.0.1'
;
$reddis_server
=
'127.0.0.1'
;
$reddis_server
=
'127.0.0.1'
;
$secret_string
=
'changeme'
;
$secret_string
=
'changeme'
;
$current_url
=
get
C
lean
U
rl
(
$secret_string
);
$current_url
=
get
_c
lean
_u
rl
(
$secret_string
);
$redis_key
=
md5
(
$current_url
);
$redis_key
=
md5
(
$current_url
);
handle
CDNR
emote
A
ddressing
();
handle
_cdn_r
emote
_a
ddressing
();
if
(
!
defined
(
'WP_USE_THEMES'
))
{
if
(
!
defined
(
'WP_USE_THEMES'
))
{
define
(
'WP_USE_THEMES'
,
true
);
define
(
'WP_USE_THEMES'
,
true
);
...
@@ -72,7 +72,7 @@ try {
...
@@ -72,7 +72,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
HasS
ecret
(
$secret_string
)
||
request
HasS
ecret
(
$secret_string
)
||
is
R
emote
P
age
L
oad
(
$current_url
,
$websiteIp
))
{
if
(
refresh
_has_s
ecret
(
$secret_string
)
||
request
_has_s
ecret
(
$secret_string
)
||
is
_r
emote
_p
age
_l
oad
(
$current_url
,
$websiteIp
))
{
if
(
$debug
)
{
if
(
$debug
)
{
echo
"<!-- manual refresh was required -->
\n
"
;
echo
"<!-- manual refresh was required -->
\n
"
;
}
}
...
@@ -136,7 +136,7 @@ try {
...
@@ -136,7 +136,7 @@ try {
}
}
$end
=
microtime
();
$end
=
microtime
();
$time
=
(
@
get
M
icro
T
ime
(
$end
)
-
@
get
M
icro
T
ime
(
$start
));
$time
=
(
@
get
_m
icro
_t
ime
(
$end
)
-
@
get
_m
icro
_t
ime
(
$start
));
if
(
$debug
)
{
if
(
$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 = "
.
$cache
.
" -->
\n
"
;
echo
"<!-- Site was cached = "
.
$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