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
f9274970
Commit
f9274970
authored
11 years ago
by
Rueben Ramirez
Browse files
Options
Downloads
Patches
Plain Diff
cleaning up
parent
7050c484
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
index-wp-redis.php
+26
-30
26 additions, 30 deletions
index-wp-redis.php
index.php
+0
-6
0 additions, 6 deletions
index.php
with
26 additions
and
36 deletions
index-wp-redis.php
+
26
−
30
View file @
f9274970
...
...
@@ -11,7 +11,7 @@ function getMicroTime($t)
$debug
=
true
;
$cache
=
false
;
$cache
=
false
;
$ip_of_your_website
=
'127.0.0.1'
;
$secret_string
=
'changeme'
;
...
...
@@ -53,10 +53,10 @@ try {
// This page is cached, lets display it
}
else
if
(
$redis
->
exists
(
$redis_key
))
{
$cache
=
true
;
$cache
=
true
;
$html_of_page
=
$redis
->
get
(
$redis_key
);
echo
$html_of_page
;
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
}
else
if
(
$_SERVER
[
'REMOTE_ADDR'
]
!=
$ip_of_your_website
&&
strstr
(
$current_url
,
'preview=true'
)
==
false
)
{
...
...
@@ -68,36 +68,32 @@ try {
require
(
'./wp-blog-header.php'
);
$html_of_page
=
ob_get_contents
();
ob_end_clean
();
echo
$html_of_page
;
$unlimited
=
get_option
(
'wp-redis-cache-debug'
,
false
);
$seconds_cache_redis
=
get_option
(
'wp-redis-cache-seconds'
,
43200
);
if
(
!
is_numeric
(
$seconds_cache_redis
))
{
$seconds_cache_redis
=
43200
;
}
// When a page displays after an "HTTP 404: Not Found" error occurs, do not cache
// When the search was used, do not cache
echo
$html_of_page
;
$unlimited
=
get_option
(
'wp-redis-cache-debug'
,
false
);
$seconds_cache_redis
=
get_option
(
'wp-redis-cache-seconds'
,
43200
);
if
(
!
is_numeric
(
$seconds_cache_redis
))
{
$seconds_cache_redis
=
43200
;
}
// 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
())
and
(
!
is_search
()))
{
if
(
$unlimited
)
{
$redis
->
set
(
$redis_key
,
$html_of_page
);
$redis
->
set
(
$redis_key
,
$html_of_page
);
}
else
{
$redis
->
setex
(
$redis_key
,
$seconds_cache_redis
,
$html_of_page
);
}
else
{
$redis
->
setex
(
$redis_key
,
$seconds_cache_redis
,
$html_of_page
);
}
}
}
else
//either the user is logged in, or is posting a comment, show them uncached
{
}
else
{
//either the user is logged in, or is posting a comment, show them uncached
require
(
'./wp-blog-header.php'
);
}
}
else
if
(
$_SERVER
[
'REMOTE_ADDR'
]
!=
$ip_of_your_website
&&
strstr
(
$current_url
,
'preview=true'
)
==
true
)
{
require
(
'./wp-blog-header.php'
);
}
// else { // This is what your server should get if no cache exists //depr
i
cated, as the ob_start() is cleaner
// else { // This is what your server should get if no cache exists //depr
e
cated, as the ob_start() is cleaner
// require('./wp-blog-header.php');
// }
}
catch
(
Exception
$e
)
{
...
...
@@ -108,12 +104,12 @@ try {
$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
.
"-->"
;
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
.
"-->"
;
}
This diff is collapsed.
Click to expand it.
index.php
+
0
−
6
View file @
f9274970
<?php
require
(
'index-wp-redis.php'
);
//define('WP_USE_THEMES', true);
//require('./wp-blog-header.php');
?>
\ No newline at end of file
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