Version Description
Download this release
Release Info
Developer | donncha |
Plugin | WP Super Cache |
Version | 0.9.2 |
Comparing to | |
See all releases |
Code changes from version 0.9.1 to 0.9.2
- Changelog.txt +127 -0
- advanced-cache.php +1 -1
- plugins/badbehaviour.php +23 -3
- readme.txt +20 -12
- wp-cache-phase1.php +13 -10
- wp-cache-phase2.php +88 -79
- wp-cache.php +20 -11
Changelog.txt
CHANGED
@@ -1,3 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
2009-02-26 11:53 donncha
|
2 |
|
3 |
* Changelog.txt: Updated changelog
|
1 |
+
2009-03-30 16:12 donncha
|
2 |
+
|
3 |
+
* wp-cache-phase2.php: Added an "auto reject" list of URIs
|
4 |
+
|
5 |
+
2009-03-30 06:22 donncha
|
6 |
+
|
7 |
+
* wp-cache-phase1.php: Remove corrupted or obsolete meta file and
|
8 |
+
cache file.
|
9 |
+
|
10 |
+
2009-03-30 04:53 donncha
|
11 |
+
|
12 |
+
* wp-cache-phase1.php, wp-cache-phase2.php: Don't use array_push().
|
13 |
+
Removed wp_cache_file_contents action as it may contribute to
|
14 |
+
memory problems for some hosts.
|
15 |
+
Pass buffer by reference to ob function.
|
16 |
+
Revert merge of shutdown function and ob function
|
17 |
+
Pass "siteurl" to post_id gc function
|
18 |
+
|
19 |
+
2009-03-29 16:32 donncha
|
20 |
+
|
21 |
+
* wp-cache-phase1.php: Make sure $meta is an array
|
22 |
+
|
23 |
+
2009-03-28 13:03 donncha
|
24 |
+
|
25 |
+
* Changelog.txt: Updated changelog
|
26 |
+
|
27 |
+
2009-03-28 13:02 donncha
|
28 |
+
|
29 |
+
* readme.txt, wp-cache.php: Bump version number to 0.9.2
|
30 |
+
|
31 |
+
2009-03-28 12:58 donncha
|
32 |
+
|
33 |
+
* readme.txt: Added a troubleshooting entry for advanced-cache.php
|
34 |
+
|
35 |
+
2009-03-28 12:54 donncha
|
36 |
+
|
37 |
+
* advanced-cache.php: Include once instead of require because it
|
38 |
+
won't cause a FATAL error if the path is incorrect
|
39 |
+
|
40 |
+
2009-03-28 12:39 donncha
|
41 |
+
|
42 |
+
* readme.txt: Minimum version is now 2.6, props tigertech,
|
43 |
+
http://wordpress.org/support/topic/255628?replies=1
|
44 |
+
|
45 |
+
2009-03-28 12:34 donncha
|
46 |
+
|
47 |
+
* wp-cache-phase2.php: Delete static "pages on front" when posts
|
48 |
+
change.
|
49 |
+
|
50 |
+
2009-03-28 12:30 donncha
|
51 |
+
|
52 |
+
* readme.txt: Move uninstall instructions up
|
53 |
+
Added "If all else fails" instructions
|
54 |
+
|
55 |
+
2009-03-21 21:15 donncha
|
56 |
+
|
57 |
+
* wp-cache.php: Added "Settings" link on plugins page.
|
58 |
+
Simplified admin notice, may fix 500 internal errors
|
59 |
+
|
60 |
+
2009-03-21 21:13 donncha
|
61 |
+
|
62 |
+
* wp-cache-phase1.php, wp-cache-phase2.php, wp-cache.php: Revert
|
63 |
+
moving meta information into cache file. It took too long to scan
|
64 |
+
the directory
|
65 |
+
|
66 |
+
2009-03-20 15:34 donncha
|
67 |
+
|
68 |
+
* wp-cache-phase2.php: Unlink supercache cache files as well as
|
69 |
+
wp-cache files
|
70 |
+
|
71 |
+
2009-03-20 15:33 donncha
|
72 |
+
|
73 |
+
* wp-cache-phase2.php: No need for separate $log variable
|
74 |
+
|
75 |
+
2009-03-20 15:31 donncha
|
76 |
+
|
77 |
+
* wp-cache-phase2.php: $supercacheonly is set further up
|
78 |
+
|
79 |
+
2009-03-20 15:30 donncha
|
80 |
+
|
81 |
+
* wp-cache-phase2.php: Minor typos "attac"
|
82 |
+
Removed unused function
|
83 |
+
|
84 |
+
2009-03-20 15:28 donncha
|
85 |
+
|
86 |
+
* wp-cache-phase2.php: Make sure other actions have a chance to
|
87 |
+
mark comments as spam
|
88 |
+
|
89 |
+
2009-03-13 22:19 donncha
|
90 |
+
|
91 |
+
* wp-cache-phase1.php: Don't need that error_log
|
92 |
+
|
93 |
+
2009-03-13 11:41 donncha
|
94 |
+
|
95 |
+
* wp-cache-phase1.php, wp-cache-phase2.php, wp-cache.php: Make meta
|
96 |
+
an array rather than an object because of this change to PHP5:
|
97 |
+
http://bugs.php.net/bug.php?id=40104
|
98 |
+
Move meta file data into cache file.
|
99 |
+
|
100 |
+
2009-03-13 09:06 donncha
|
101 |
+
|
102 |
+
* wp-cache-phase2.php: Move wp_cache_shutdown_callback() into the
|
103 |
+
ob callback
|
104 |
+
|
105 |
+
2009-03-09 09:52 donncha
|
106 |
+
|
107 |
+
* wp-cache.php: Only check for apache modules if in supercache
|
108 |
+
mode.
|
109 |
+
|
110 |
+
2009-02-27 09:55 donncha
|
111 |
+
|
112 |
+
* plugins/badbehaviour.php: Note that compression disabled when BB
|
113 |
+
support enabled.
|
114 |
+
|
115 |
+
2009-02-27 09:46 donncha
|
116 |
+
|
117 |
+
* plugins/badbehaviour.php: Bad-behavior fixes. Plugin will find
|
118 |
+
the bb plugin folder now.
|
119 |
+
|
120 |
+
2009-02-26 12:55 donncha
|
121 |
+
|
122 |
+
* wp-cache-phase1.php: set the right variable.
|
123 |
+
|
124 |
+
2009-02-26 11:53 donncha
|
125 |
+
|
126 |
+
* Changelog.txt: Updated changelog, should have svnupped last time
|
127 |
+
|
128 |
2009-02-26 11:53 donncha
|
129 |
|
130 |
* Changelog.txt: Updated changelog
|
advanced-cache.php
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
<?php
|
2 |
# WP SUPER CACHE 0.8.9.1
|
3 |
-
|
4 |
?>
|
1 |
<?php
|
2 |
# WP SUPER CACHE 0.8.9.1
|
3 |
+
include_once( 'CACHEHOME' . 'wp-cache-phase1.php' );
|
4 |
?>
|
plugins/badbehaviour.php
CHANGED
@@ -11,7 +11,24 @@ function wp_supercache_badbehaviour( $file ) {
|
|
11 |
add_cacheaction( 'wp_cache_served_cache_file', 'wp_supercache_badbehaviour' );
|
12 |
|
13 |
function wp_supercache_badbehaviour_include() {
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
|
17 |
function wp_supercache_badbehaviour_admin() {
|
@@ -22,12 +39,15 @@ function wp_supercache_badbehaviour_admin() {
|
|
22 |
$err = false;
|
23 |
|
24 |
if(isset($_POST['cache_badbehaviour']) && $valid_nonce) {
|
25 |
-
|
|
|
26 |
$_POST[ 'cache_badbehaviour' ] = 'Disable';
|
27 |
$err = 'Bad Behaviour not found. Please check your install.';
|
28 |
}
|
29 |
$cache_badbehaviour = $_POST['cache_badbehaviour'] == 'Disable' ? 0 : 1;
|
|
|
30 |
wp_cache_replace_line('^ *\$cache_badbehaviour', "\$cache_badbehaviour = $cache_badbehaviour;", $wp_cache_config_file);
|
|
|
31 |
}
|
32 |
echo '<form name="wp_supercache_badbehaviour_admin" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
33 |
wp_nonce_field('wp-cache');
|
@@ -38,7 +58,7 @@ function wp_supercache_badbehaviour_admin() {
|
|
38 |
echo 'enabled';
|
39 |
wp_super_cache_disable();
|
40 |
}
|
41 |
-
echo '.</strong> (Only half-on caching supported and requires <a href="http://www.bad-behavior.ioerror.us/">Bad Behaviour</a> in "' . WP_CONTENT_DIR . '/plugins/
|
42 |
if( $cache_badbehaviour == 0 ) {
|
43 |
echo '<input type="submit" name="cache_badbehaviour" value="Enable" />';
|
44 |
} else {
|
11 |
add_cacheaction( 'wp_cache_served_cache_file', 'wp_supercache_badbehaviour' );
|
12 |
|
13 |
function wp_supercache_badbehaviour_include() {
|
14 |
+
$bbfile = get_bb_file_loc();
|
15 |
+
if( !$bbfile )
|
16 |
+
require_once( $bbfile );
|
17 |
+
}
|
18 |
+
|
19 |
+
function get_bb_file_loc() {
|
20 |
+
global $cache_badbehaviour_file;
|
21 |
+
if( $cache_badbehaviour_file )
|
22 |
+
return $cache_badbehaviour_file;
|
23 |
+
|
24 |
+
if( file_exists( WP_CONTENT_DIR . '/plugins/bad-behavior/bad-behavior-generic.php' ) ) {
|
25 |
+
$bbfile = WP_CONTENT_DIR . '/plugins/bad-behavior/bad-behavior-generic.php';
|
26 |
+
} elseif( file_exists( WP_CONTENT_DIR . '/plugins/Bad-Behavior/bad-behavior-generic.php' ) ) {
|
27 |
+
$bbfile = WP_CONTENT_DIR . '/plugins/Bad-Behavior/bad-behavior-generic.php';
|
28 |
+
} else {
|
29 |
+
$bbfile = false;
|
30 |
+
}
|
31 |
+
return $bbfile;
|
32 |
}
|
33 |
|
34 |
function wp_supercache_badbehaviour_admin() {
|
39 |
$err = false;
|
40 |
|
41 |
if(isset($_POST['cache_badbehaviour']) && $valid_nonce) {
|
42 |
+
$bbfile = get_bb_file_loc();
|
43 |
+
if( !$bbfile ) {
|
44 |
$_POST[ 'cache_badbehaviour' ] = 'Disable';
|
45 |
$err = 'Bad Behaviour not found. Please check your install.';
|
46 |
}
|
47 |
$cache_badbehaviour = $_POST['cache_badbehaviour'] == 'Disable' ? 0 : 1;
|
48 |
+
wp_cache_replace_line('^ *\$cache_compression', "\$cache_compression = 0;", $wp_cache_config_file);
|
49 |
wp_cache_replace_line('^ *\$cache_badbehaviour', "\$cache_badbehaviour = $cache_badbehaviour;", $wp_cache_config_file);
|
50 |
+
wp_cache_replace_line('^ *\$cache_badbehaviour_file', "\$cache_badbehaviour_file = '$bbfile';", $wp_cache_config_file);
|
51 |
}
|
52 |
echo '<form name="wp_supercache_badbehaviour_admin" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
53 |
wp_nonce_field('wp-cache');
|
58 |
echo 'enabled';
|
59 |
wp_super_cache_disable();
|
60 |
}
|
61 |
+
echo '.</strong> (Only half-on caching supported, disabled compression and requires <a href="http://www.bad-behavior.ioerror.us/">Bad Behaviour</a> in "' . WP_CONTENT_DIR . '/plugins/bad-behavior/") ';
|
62 |
if( $cache_badbehaviour == 0 ) {
|
63 |
echo '<input type="submit" name="cache_badbehaviour" value="Enable" />';
|
64 |
} else {
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: donncha
|
3 |
Tags: performance,caching,wp-cache,wp-super-cache,cache
|
4 |
Tested up to: 2.7.1
|
5 |
-
Stable tag: 0.9.
|
6 |
-
Requires at least: 2.
|
7 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3244504
|
8 |
|
9 |
A very fast caching engine for WordPress that produces static html files.
|
@@ -81,6 +81,22 @@ The [changelog](http://svn.wp-plugins.org/wp-super-cache/trunk/Changelog.txt) is
|
|
81 |
`<Directory /home/www/>`
|
82 |
`AllowOverride All`
|
83 |
`</Directory>`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
== Frequently Asked Questions ==
|
86 |
|
@@ -108,19 +124,10 @@ This plugin caches entire pages and some plugins expect they can run PHP code ev
|
|
108 |
|
109 |
Those bots usually only visit each page once and if the page is not popular there's no point creating a cache file that will sit idle on your server.
|
110 |
|
111 |
-
= Why
|
112 |
|
113 |
Like the previous question, there's no point caching pages that won't be visited. The large number of cache files will slow down the garbage collection system as it attempts to check each file. It also causes problems for hosting companies. In the event of a disk failure on your server it may take much longer to check the files. Remember how long a scandisk or a fsck took on a large drive?
|
114 |
|
115 |
-
= How do I uninstall WP Super Cache? =
|
116 |
-
|
117 |
-
1. Clear the cache in the backend page and then deactivate it on the plugins page.
|
118 |
-
2. Remove the Super Cache mod_rewrite rules from your .htaccess file.
|
119 |
-
3. Remove the WP_CACHE define from wp-config.php
|
120 |
-
4. Remove the files wp-content/advanced-cache.php and wp-content/wp-cache-config.php
|
121 |
-
5. Remove the directory wp-content/cache/
|
122 |
-
6. Remove the directory wp-super-cache from your plugins directory.
|
123 |
-
|
124 |
= Troubleshooting =
|
125 |
|
126 |
If things don't work when you installed the plugin here are a few things to check:
|
@@ -147,6 +154,7 @@ If things don't work when you installed the plugin here are a few things to chec
|
|
147 |
`127.0.0.1 myhostname.com`
|
148 |
A line like "127.0.0.1 localhost localhost.localdomain" is ok.
|
149 |
17. If old pages are being served to your visitors via the supercache, you may be missing Apache modules (or their equivalents if you don't use Apache). 3 modules are required: mod_mime, mod_headers and mod_expires. The last two are especially important for making sure browsers load new versions of existing pages on your site.
|
|
|
150 |
|
151 |
== Custom Caching ==
|
152 |
It is now possible to hook into the caching process using the add_cacheaction() function.
|
2 |
Contributors: donncha
|
3 |
Tags: performance,caching,wp-cache,wp-super-cache,cache
|
4 |
Tested up to: 2.7.1
|
5 |
+
Stable tag: 0.9.2
|
6 |
+
Requires at least: 2.6
|
7 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3244504
|
8 |
|
9 |
A very fast caching engine for WordPress that produces static html files.
|
81 |
`<Directory /home/www/>`
|
82 |
`AllowOverride All`
|
83 |
`</Directory>`
|
84 |
+
10. wp-content/advanced-cache.php loads the caching engine. This file is generated by the plugin. Make sure the path in the include_once() is correct.
|
85 |
+
|
86 |
+
== How to uninstall WP Super Cache ==
|
87 |
+
|
88 |
+
1. Remove the WP_CACHE define from wp-config.php. It looks like `define( 'WP_CACHE', true );`
|
89 |
+
2. Clear the cache in the backend page and then deactivate the plugin on the plugins page.
|
90 |
+
3. Remove the Super Cache mod_rewrite rules from your .htaccess file.
|
91 |
+
4. Remove the files wp-content/advanced-cache.php and wp-content/wp-cache-config.php
|
92 |
+
5. Remove the directory wp-content/cache/
|
93 |
+
6. Remove the directory wp-super-cache from your plugins directory.
|
94 |
+
|
95 |
+
If all else fails and your site is broken and you want to disable the plugin:
|
96 |
+
1. Remove the WP_CACHE define from wp-config.php. It looks like `define( 'WP_CACHE', true );`
|
97 |
+
2. Remove the rules (see above) that the plugin wrote to the .htaccess file in your root directory.
|
98 |
+
3. Delete the wp-super-cache folder in the plugins folder.
|
99 |
+
4. Optionally delete advanced-cache.php, wp-cache-config.php and the cache folder in wp-content/.
|
100 |
|
101 |
== Frequently Asked Questions ==
|
102 |
|
124 |
|
125 |
Those bots usually only visit each page once and if the page is not popular there's no point creating a cache file that will sit idle on your server.
|
126 |
|
127 |
+
= Why shouldn't I create a cache file of every page on my site? =
|
128 |
|
129 |
Like the previous question, there's no point caching pages that won't be visited. The large number of cache files will slow down the garbage collection system as it attempts to check each file. It also causes problems for hosting companies. In the event of a disk failure on your server it may take much longer to check the files. Remember how long a scandisk or a fsck took on a large drive?
|
130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
= Troubleshooting =
|
132 |
|
133 |
If things don't work when you installed the plugin here are a few things to check:
|
154 |
`127.0.0.1 myhostname.com`
|
155 |
A line like "127.0.0.1 localhost localhost.localdomain" is ok.
|
156 |
17. If old pages are being served to your visitors via the supercache, you may be missing Apache modules (or their equivalents if you don't use Apache). 3 modules are required: mod_mime, mod_headers and mod_expires. The last two are especially important for making sure browsers load new versions of existing pages on your site.
|
157 |
+
18. Open the file wp-content/advanced-cache.php in your favourite editor. Is the path to wp-cache-phase1.php correct? If it is not the caching engine will not load.
|
158 |
|
159 |
== Custom Caching ==
|
160 |
It is now possible to hook into the caching process using the add_cacheaction() function.
|
wp-cache-phase1.php
CHANGED
@@ -9,7 +9,6 @@ if( !defined( 'WPCACHEHOME' ) )
|
|
9 |
define('WPCACHEHOME', dirname(__FILE__).'/');
|
10 |
|
11 |
include( WPCACHEHOME . 'wp-cache-base.php');
|
12 |
-
$wp_cache_meta_object = new CacheMeta;
|
13 |
|
14 |
if(defined('DOING_CRON')) {
|
15 |
require_once( WPCACHEHOME . 'wp-cache-phase2.php');
|
@@ -66,18 +65,22 @@ $meta_pathname = realpath( $cache_path . 'meta/' . $meta_file );
|
|
66 |
$wp_start_time = microtime();
|
67 |
if( file_exists( $cache_file ) && ($mtime = @filemtime($meta_pathname)) ) {
|
68 |
if ($mtime + $cache_max_time > time() ) {
|
69 |
-
|
70 |
if (! ($meta = unserialize(@file_get_contents($meta_pathname))) )
|
71 |
return;
|
72 |
-
$
|
|
|
|
|
|
|
|
|
|
|
73 |
// Sometimes the gzip headers are lost. If this is a gzip capable client, send those headers.
|
74 |
-
if( $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $meta
|
75 |
-
|
76 |
-
|
77 |
-
array_push($meta->headers, 'Content-Length: ' . filesize( $cache_file ) );
|
78 |
wp_cache_debug( "Had to add gzip headers to the page {$_SERVER[ 'REQUEST_URI' ]}." );
|
79 |
}
|
80 |
-
foreach ($meta
|
81 |
// godaddy fix, via http://blog.gneu.org/2008/05/wp-supercache-on-godaddy/ and http://www.littleredrails.com/blog/2007/09/08/using-wp-cache-on-godaddy-500-error/
|
82 |
if( strpos( $header, 'Last-Modified:' ) === false )
|
83 |
header($header);
|
@@ -85,10 +88,10 @@ if( file_exists( $cache_file ) && ($mtime = @filemtime($meta_pathname)) ) {
|
|
85 |
header( 'WP-Super-Cache: WP-Cache' );
|
86 |
if ( !($content_size = @filesize($cache_file)) > 0 || $mtime < @filemtime($cache_file))
|
87 |
return;
|
88 |
-
if ($meta
|
89 |
include($cache_file);
|
90 |
} else {
|
91 |
-
|
92 |
}
|
93 |
die();
|
94 |
}
|
9 |
define('WPCACHEHOME', dirname(__FILE__).'/');
|
10 |
|
11 |
include( WPCACHEHOME . 'wp-cache-base.php');
|
|
|
12 |
|
13 |
if(defined('DOING_CRON')) {
|
14 |
require_once( WPCACHEHOME . 'wp-cache-phase2.php');
|
65 |
$wp_start_time = microtime();
|
66 |
if( file_exists( $cache_file ) && ($mtime = @filemtime($meta_pathname)) ) {
|
67 |
if ($mtime + $cache_max_time > time() ) {
|
68 |
+
|
69 |
if (! ($meta = unserialize(@file_get_contents($meta_pathname))) )
|
70 |
return;
|
71 |
+
if( is_array( $meta ) == false ) {
|
72 |
+
@unlink( $meta_pathname );
|
73 |
+
@unlink( $cache_file );
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
$cache_file = do_cacheaction( 'wp_cache_served_cache_file', $cache_file );
|
77 |
// Sometimes the gzip headers are lost. If this is a gzip capable client, send those headers.
|
78 |
+
if( $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $meta[ 'headers' ] ) ) {
|
79 |
+
$meta[ 'headers' ][ 'Content-Encoding' ] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
|
80 |
+
$meta[ 'headers' ][ 'Vary' ] = 'Vary: Accept-Encoding, Cookie';
|
|
|
81 |
wp_cache_debug( "Had to add gzip headers to the page {$_SERVER[ 'REQUEST_URI' ]}." );
|
82 |
}
|
83 |
+
foreach ($meta[ 'headers' ] as $t => $header) {
|
84 |
// godaddy fix, via http://blog.gneu.org/2008/05/wp-supercache-on-godaddy/ and http://www.littleredrails.com/blog/2007/09/08/using-wp-cache-on-godaddy-500-error/
|
85 |
if( strpos( $header, 'Last-Modified:' ) === false )
|
86 |
header($header);
|
88 |
header( 'WP-Super-Cache: WP-Cache' );
|
89 |
if ( !($content_size = @filesize($cache_file)) > 0 || $mtime < @filemtime($cache_file))
|
90 |
return;
|
91 |
+
if ( $meta[ 'dynamic' ] ) {
|
92 |
include($cache_file);
|
93 |
} else {
|
94 |
+
readfile( $cache_file );
|
95 |
}
|
96 |
die();
|
97 |
}
|
wp-cache-phase2.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
function wp_cache_phase2() {
|
4 |
-
global $cache_filename, $cache_acceptable_files, $
|
5 |
|
6 |
$wp_cache_gmt_offset = get_option( 'gmt_offset' ); // caching for later use when wpdb is gone. http://wordpress.org/support/topic/224349
|
7 |
|
@@ -13,14 +13,14 @@ function wp_cache_phase2() {
|
|
13 |
add_action('delete_post', 'wp_cache_post_edit', 0);
|
14 |
add_action('publish_phone', 'wp_cache_post_edit', 0);
|
15 |
// Coment ID is received
|
16 |
-
add_action('trackback_post', 'wp_cache_get_postid_from_comment',
|
17 |
-
add_action('pingback_post', 'wp_cache_get_postid_from_comment',
|
18 |
-
add_action('comment_post', 'wp_cache_get_postid_from_comment',
|
19 |
-
add_action('edit_comment', 'wp_cache_get_postid_from_comment',
|
20 |
-
add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment',
|
21 |
// No post_id is available
|
22 |
-
add_action('delete_comment', 'wp_cache_no_postid',
|
23 |
-
add_action('switch_theme', 'wp_cache_no_postid',
|
24 |
|
25 |
add_action('wp_cache_gc','wp_cache_gc_cron');
|
26 |
|
@@ -80,8 +80,11 @@ function wp_cache_get_response_headers() {
|
|
80 |
function wp_cache_is_rejected($uri) {
|
81 |
global $cache_rejected_uri;
|
82 |
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
85 |
foreach ($cache_rejected_uri as $expr) {
|
86 |
if( preg_match( "~$expr~", $uri ) )
|
87 |
return true;
|
@@ -156,7 +159,7 @@ function get_current_url_supercache_dir() {
|
|
156 |
global $cached_direct_pages, $cache_path;
|
157 |
$uri = preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '/index.php', '/', str_replace( '..', '', preg_replace("/(\?.*)?$/", '', $_SERVER['REQUEST_URI'] ) ) ) );
|
158 |
$uri = str_replace( '\\', '', $uri );
|
159 |
-
$dir = strtolower(preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"])) . $uri; // To avoid XSS
|
160 |
$dir = apply_filters( 'supercache_dir', $dir );
|
161 |
$dir = trailingslashit( $cache_path . 'supercache/' . $dir );
|
162 |
if( is_array( $cached_direct_pages ) && in_array( $_SERVER[ 'REQUEST_URI' ], $cached_direct_pages ) ) {
|
@@ -167,19 +170,20 @@ function get_current_url_supercache_dir() {
|
|
167 |
}
|
168 |
|
169 |
function wp_cache_ob_callback( $buffer ) {
|
170 |
-
$buffer = wp_cache_get_ob( $buffer );
|
171 |
wp_cache_shutdown_callback();
|
172 |
return $buffer;
|
173 |
}
|
174 |
|
175 |
|
176 |
-
function wp_cache_get_ob(
|
177 |
global $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
|
178 |
-
global $new_cache, $
|
179 |
global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
|
180 |
global $wp_cache_404, $gzsize, $supercacheonly, $wp_cache_gzip_first, $wp_cache_gmt_offset;
|
181 |
|
182 |
$new_cache = true;
|
|
|
183 |
|
184 |
/* Mode paranoic, check for closing tags
|
185 |
* we avoid caching incomplete files */
|
@@ -199,7 +203,7 @@ function wp_cache_get_ob($buffer) {
|
|
199 |
|
200 |
$duration = wp_cache_microtime_diff($wp_start_time, microtime());
|
201 |
$duration = sprintf("%0.3f", $duration);
|
202 |
-
$buffer .= "\n<!-- Dynamic
|
203 |
|
204 |
if( !wp_cache_writers_entry() ) {
|
205 |
$buffer .= "\n<!-- Page not cached by WP Super Cache. Could not get mutex lock. -->\n";
|
@@ -269,7 +273,7 @@ function wp_cache_get_ob($buffer) {
|
|
269 |
$store = preg_replace('|<!--mfunc (.*?)-->(.*?)<!--/mfunc-->|is',
|
270 |
"<!--mfunc-->\n<?php $1 ;?>\n<!--/mfunc-->", $store);
|
271 |
$store = apply_filters( 'wpsupercache_buffer', $store );
|
272 |
-
$
|
273 |
/* Clean function calls in tag */
|
274 |
$buffer = preg_replace('|<!--mclude (.*?)-->|is', '<!--mclude-->', $buffer);
|
275 |
$buffer = preg_replace('|<!--mfunc (.*?)-->|is', '<!--mfunc-->', $buffer);
|
@@ -281,26 +285,25 @@ function wp_cache_get_ob($buffer) {
|
|
281 |
fputs($gz, gzencode( $store . '<!-- super cache gz -->', 1, FORCE_GZIP ) );
|
282 |
} else {
|
283 |
$buffer = apply_filters( 'wpsupercache_buffer', $buffer );
|
284 |
-
$
|
285 |
|
286 |
if( $gz || $wp_cache_gzip_encoding ) {
|
287 |
-
$gzdata = gzencode( $buffer .
|
288 |
$gzsize = strlen($gzdata);
|
289 |
}
|
290 |
if ($wp_cache_gzip_encoding) {
|
291 |
-
|
292 |
-
|
293 |
-
array_push($wp_cache_meta_object->headers, 'Content-Length: ' . $gzsize);
|
294 |
// Return uncompressed data & store compressed for later use
|
295 |
if( $fr )
|
296 |
fputs($fr, $gzdata);
|
297 |
} else { // no compression
|
298 |
-
|
299 |
if( $fr )
|
300 |
-
fputs($fr, $buffer
|
301 |
}
|
302 |
if( $fr2 )
|
303 |
-
fputs($fr2, $buffer .
|
304 |
if( $gz )
|
305 |
fwrite($gz, $gzdata );
|
306 |
$buffer .= $log;
|
@@ -446,34 +449,25 @@ function wp_cache_phase2_clean_expired($file_prefix) {
|
|
446 |
}
|
447 |
|
448 |
function wp_cache_shutdown_callback() {
|
449 |
-
global $cache_path, $cache_max_time, $file_expired, $file_prefix, $meta_file, $new_cache, $
|
450 |
|
451 |
$supercacheonly = false;
|
452 |
|
453 |
-
$
|
454 |
-
$
|
455 |
-
$
|
456 |
|
457 |
$response = wp_cache_get_response_headers();
|
458 |
foreach ($known_headers as $key) {
|
459 |
if(isset($response[$key])) {
|
460 |
-
|
461 |
}
|
462 |
}
|
463 |
-
/* Not used because it gives problems with some
|
464 |
-
* PHP installations
|
465 |
-
if (!$response{'Content-Length'}) {
|
466 |
-
// WP does not set content size
|
467 |
-
$content_size = ob_get_length();
|
468 |
-
@header("Content-Length: $content_size");
|
469 |
-
array_push($wp_cache_meta_object->headers, "Content-Length: $content_size");
|
470 |
-
}
|
471 |
-
*/
|
472 |
if (!isset( $response['Last-Modified'] )) {
|
473 |
$value = gmdate('D, d M Y H:i:s') . ' GMT';
|
474 |
/* Dont send this the first time */
|
475 |
/* @header('Last-Modified: ' . $value); */
|
476 |
-
|
477 |
}
|
478 |
if (!$response['Content-Type'] && !$response['Content-type']) {
|
479 |
// On some systems, headers set by PHP can't be fetched from
|
@@ -501,32 +495,31 @@ function wp_cache_shutdown_callback() {
|
|
501 |
$value .= "; charset=\"" . get_option('blog_charset') . "\"";
|
502 |
|
503 |
@header("Content-Type: $value");
|
504 |
-
|
505 |
}
|
506 |
|
507 |
if ( ! $supercacheonly && $new_cache ) {
|
508 |
-
if( $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $
|
509 |
-
|
510 |
-
|
511 |
-
array_push($wp_cache_meta_object->headers, 'Content-Length: ' . filesize( $cache_path . $cache_filename ));
|
512 |
}
|
513 |
|
514 |
-
$serial = serialize($
|
515 |
-
if(
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
|
|
528 |
}
|
529 |
-
wp_cache_writers_exit();
|
530 |
}
|
531 |
|
532 |
if( !isset( $cache_max_time ) )
|
@@ -535,21 +528,20 @@ function wp_cache_shutdown_callback() {
|
|
535 |
|
536 |
if( !$last_gc ) {
|
537 |
update_option( 'wpsupercache_gc_time', time() );
|
538 |
-
return;
|
539 |
}
|
540 |
|
541 |
$next_gc = $cache_max_time < 1800 ? $cache_max_time : 600;
|
542 |
-
if( $last_gc
|
543 |
-
|
544 |
-
update_option( 'wpsupercache_gc_time', time() );
|
545 |
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
|
|
553 |
}
|
554 |
}
|
555 |
|
@@ -587,6 +579,20 @@ function wp_cache_post_edit($post_id) {
|
|
587 |
}
|
588 |
}
|
589 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
590 |
function wp_cache_post_change($post_id) {
|
591 |
global $file_prefix, $cache_path, $blog_id, $blogcacheid, $super_cache_enabled;
|
592 |
static $last_processed = -1;
|
@@ -602,16 +608,13 @@ function wp_cache_post_change($post_id) {
|
|
602 |
// make sure the front page has a rebuild file
|
603 |
prune_super_cache( $cache_path . 'supercache/' . $siteurl . 'index.html', true, true );
|
604 |
prune_super_cache( $cache_path . 'supercache/' . $siteurl . 'index.html.gz', true, true );
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
@rmdir( $dir . $permalink );
|
610 |
-
prune_super_cache( $dir . 'page/', true );
|
611 |
}
|
612 |
}
|
613 |
|
614 |
-
$meta = new CacheMeta;
|
615 |
$matches = array();
|
616 |
if ( ($handle = opendir( $cache_path . 'meta/' )) ) {
|
617 |
while ( false !== ($file = readdir($handle))) {
|
@@ -619,14 +622,20 @@ function wp_cache_post_change($post_id) {
|
|
619 |
$meta_pathname = $cache_path . 'meta/' . $file;
|
620 |
$content_pathname = $cache_path . $matches[1] . ".html";
|
621 |
$meta = unserialize(@file_get_contents($meta_pathname));
|
|
|
|
|
622 |
if ($post_id > 0 && $meta) {
|
623 |
-
if ($meta
|
624 |
@unlink($meta_pathname);
|
625 |
@unlink($content_pathname);
|
|
|
|
|
626 |
}
|
627 |
-
} elseif ($meta
|
628 |
@unlink($meta_pathname);
|
629 |
@unlink($content_pathname);
|
|
|
|
|
630 |
}
|
631 |
|
632 |
}
|
1 |
<?php
|
2 |
|
3 |
function wp_cache_phase2() {
|
4 |
+
global $cache_filename, $cache_acceptable_files, $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $wp_cache_gmt_offset;
|
5 |
|
6 |
$wp_cache_gmt_offset = get_option( 'gmt_offset' ); // caching for later use when wpdb is gone. http://wordpress.org/support/topic/224349
|
7 |
|
13 |
add_action('delete_post', 'wp_cache_post_edit', 0);
|
14 |
add_action('publish_phone', 'wp_cache_post_edit', 0);
|
15 |
// Coment ID is received
|
16 |
+
add_action('trackback_post', 'wp_cache_get_postid_from_comment', 99);
|
17 |
+
add_action('pingback_post', 'wp_cache_get_postid_from_comment', 99);
|
18 |
+
add_action('comment_post', 'wp_cache_get_postid_from_comment', 99);
|
19 |
+
add_action('edit_comment', 'wp_cache_get_postid_from_comment', 99);
|
20 |
+
add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 99);
|
21 |
// No post_id is available
|
22 |
+
add_action('delete_comment', 'wp_cache_no_postid', 99);
|
23 |
+
add_action('switch_theme', 'wp_cache_no_postid', 99);
|
24 |
|
25 |
add_action('wp_cache_gc','wp_cache_gc_cron');
|
26 |
|
80 |
function wp_cache_is_rejected($uri) {
|
81 |
global $cache_rejected_uri;
|
82 |
|
83 |
+
$auto_rejected = array( '/wp-admin/', 'xmlrpc.php', 'wp-app.php' );
|
84 |
+
foreach( $auto_rejected as $u ) {
|
85 |
+
if( strstr( $uri, $u ) )
|
86 |
+
return true; // we don't allow caching of wp-admin for security reasons
|
87 |
+
}
|
88 |
foreach ($cache_rejected_uri as $expr) {
|
89 |
if( preg_match( "~$expr~", $uri ) )
|
90 |
return true;
|
159 |
global $cached_direct_pages, $cache_path;
|
160 |
$uri = preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '/index.php', '/', str_replace( '..', '', preg_replace("/(\?.*)?$/", '', $_SERVER['REQUEST_URI'] ) ) ) );
|
161 |
$uri = str_replace( '\\', '', $uri );
|
162 |
+
$dir = strtolower(preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"])) . $uri; // To avoid XSS attacks
|
163 |
$dir = apply_filters( 'supercache_dir', $dir );
|
164 |
$dir = trailingslashit( $cache_path . 'supercache/' . $dir );
|
165 |
if( is_array( $cached_direct_pages ) && in_array( $_SERVER[ 'REQUEST_URI' ], $cached_direct_pages ) ) {
|
170 |
}
|
171 |
|
172 |
function wp_cache_ob_callback( $buffer ) {
|
173 |
+
$buffer = &wp_cache_get_ob( $buffer );
|
174 |
wp_cache_shutdown_callback();
|
175 |
return $buffer;
|
176 |
}
|
177 |
|
178 |
|
179 |
+
function wp_cache_get_ob(&$buffer) {
|
180 |
global $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
|
181 |
+
global $new_cache, $wp_cache_meta, $file_expired, $blog_id, $cache_compression;
|
182 |
global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
|
183 |
global $wp_cache_404, $gzsize, $supercacheonly, $wp_cache_gzip_first, $wp_cache_gmt_offset;
|
184 |
|
185 |
$new_cache = true;
|
186 |
+
$wp_cache_meta = '';
|
187 |
|
188 |
/* Mode paranoic, check for closing tags
|
189 |
* we avoid caching incomplete files */
|
203 |
|
204 |
$duration = wp_cache_microtime_diff($wp_start_time, microtime());
|
205 |
$duration = sprintf("%0.3f", $duration);
|
206 |
+
$buffer .= "\n<!-- Dynamic page generated in $duration seconds. -->\n";
|
207 |
|
208 |
if( !wp_cache_writers_entry() ) {
|
209 |
$buffer .= "\n<!-- Page not cached by WP Super Cache. Could not get mutex lock. -->\n";
|
273 |
$store = preg_replace('|<!--mfunc (.*?)-->(.*?)<!--/mfunc-->|is',
|
274 |
"<!--mfunc-->\n<?php $1 ;?>\n<!--/mfunc-->", $store);
|
275 |
$store = apply_filters( 'wpsupercache_buffer', $store );
|
276 |
+
$wp_cache_meta[ 'dynamic' ] = true;
|
277 |
/* Clean function calls in tag */
|
278 |
$buffer = preg_replace('|<!--mclude (.*?)-->|is', '<!--mclude-->', $buffer);
|
279 |
$buffer = preg_replace('|<!--mfunc (.*?)-->|is', '<!--mfunc-->', $buffer);
|
285 |
fputs($gz, gzencode( $store . '<!-- super cache gz -->', 1, FORCE_GZIP ) );
|
286 |
} else {
|
287 |
$buffer = apply_filters( 'wpsupercache_buffer', $buffer );
|
288 |
+
$buffer .= "<!-- Cached page generated by WP-Super-Cache on " . gmdate('Y-m-d H:i:s', (time() + ( $wp_cache_gmt_offset * 3600))) . " -->\n";
|
289 |
|
290 |
if( $gz || $wp_cache_gzip_encoding ) {
|
291 |
+
$gzdata = gzencode( $buffer . "<!-- Compression = gzip -->", 3, FORCE_GZIP );
|
292 |
$gzsize = strlen($gzdata);
|
293 |
}
|
294 |
if ($wp_cache_gzip_encoding) {
|
295 |
+
$wp_cache_meta[ 'headers' ][ 'Content-Encoding' ] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
|
296 |
+
$wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Accept-Encoding, Cookie';
|
|
|
297 |
// Return uncompressed data & store compressed for later use
|
298 |
if( $fr )
|
299 |
fputs($fr, $gzdata);
|
300 |
} else { // no compression
|
301 |
+
$wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Cookie';
|
302 |
if( $fr )
|
303 |
+
fputs($fr, $buffer);
|
304 |
}
|
305 |
if( $fr2 )
|
306 |
+
fputs($fr2, $buffer . '<!-- super cache -->' );
|
307 |
if( $gz )
|
308 |
fwrite($gz, $gzdata );
|
309 |
$buffer .= $log;
|
449 |
}
|
450 |
|
451 |
function wp_cache_shutdown_callback() {
|
452 |
+
global $cache_path, $cache_max_time, $file_expired, $file_prefix, $meta_file, $new_cache, $wp_cache_meta, $known_headers, $blog_id, $wp_cache_gzip_encoding, $gzsize, $cache_filename, $supercacheonly;
|
453 |
|
454 |
$supercacheonly = false;
|
455 |
|
456 |
+
$wp_cache_meta[ 'uri' ] = $_SERVER["SERVER_NAME"].preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI']); // To avoid XSS attacks
|
457 |
+
$wp_cache_meta[ 'blog_id' ] = $blog_id;
|
458 |
+
$wp_cache_meta[ 'post' ] = wp_cache_post_id();
|
459 |
|
460 |
$response = wp_cache_get_response_headers();
|
461 |
foreach ($known_headers as $key) {
|
462 |
if(isset($response[$key])) {
|
463 |
+
$wp_cache_meta[ 'headers' ][ $key ] = "$key: " . $response[$key];
|
464 |
}
|
465 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
466 |
if (!isset( $response['Last-Modified'] )) {
|
467 |
$value = gmdate('D, d M Y H:i:s') . ' GMT';
|
468 |
/* Dont send this the first time */
|
469 |
/* @header('Last-Modified: ' . $value); */
|
470 |
+
$wp_cache_meta[ 'headers' ][ 'Last-Modified' ] = "Last-Modified: $value";
|
471 |
}
|
472 |
if (!$response['Content-Type'] && !$response['Content-type']) {
|
473 |
// On some systems, headers set by PHP can't be fetched from
|
495 |
$value .= "; charset=\"" . get_option('blog_charset') . "\"";
|
496 |
|
497 |
@header("Content-Type: $value");
|
498 |
+
$wp_cache_meta[ 'headers' ][ 'Content-Type' ] = "Content-Type: $value";
|
499 |
}
|
500 |
|
501 |
if ( ! $supercacheonly && $new_cache ) {
|
502 |
+
if( $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $wp_cache_meta[ 'headers' ] ) ) {
|
503 |
+
$wp_cache_meta[ 'headers' ][ 'Content-Encoding' ] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
|
504 |
+
$wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Accept-Encoding, Cookie';
|
|
|
505 |
}
|
506 |
|
507 |
+
$serial = serialize($wp_cache_meta);
|
508 |
+
if( wp_cache_writers_entry() ) {
|
509 |
+
$tmp_meta_filename = $cache_path . 'meta/' . uniqid( mt_rand(), true ) . '.tmp';
|
510 |
+
$fr = @fopen( $tmp_meta_filename, 'w');
|
511 |
+
if( !$fr )
|
512 |
+
@mkdir( $cache_path . 'meta' );
|
513 |
+
$fr = fopen( $tmp_meta_filename, 'w');
|
514 |
+
fputs($fr, $serial);
|
515 |
+
fclose($fr);
|
516 |
+
@chmod( $tmp_meta_filename, 0666 & ~umask());
|
517 |
+
if( !@rename( $tmp_meta_filename, $cache_path . 'meta/' . $meta_file ) ) {
|
518 |
+
unlink( $cache_path . 'meta/' . $meta_file );
|
519 |
+
rename( $tmp_meta_filename, $cache_path . 'meta/' . $meta_file );
|
520 |
+
}
|
521 |
+
wp_cache_writers_exit();
|
522 |
}
|
|
|
523 |
}
|
524 |
|
525 |
if( !isset( $cache_max_time ) )
|
528 |
|
529 |
if( !$last_gc ) {
|
530 |
update_option( 'wpsupercache_gc_time', time() );
|
|
|
531 |
}
|
532 |
|
533 |
$next_gc = $cache_max_time < 1800 ? $cache_max_time : 600;
|
534 |
+
if( $last_gc < ( time() - $next_gc ) ) {
|
535 |
+
update_option( 'wpsupercache_gc_time', time() );
|
|
|
536 |
|
537 |
+
global $wp_cache_shutdown_gc;
|
538 |
+
if( isset( $wp_cache_shutdown_gc ) && $wp_cache_shutdown_gc == 1 ) {
|
539 |
+
do_action( 'wp_cache_gc' );
|
540 |
+
} else {
|
541 |
+
// we delete expired files, using a wordpress cron event
|
542 |
+
// since flush() does not guarantee hand-off to client - problem on Win32 and suPHP
|
543 |
+
if(!wp_next_scheduled('wp_cache_gc')) wp_schedule_single_event(time() + 10 , 'wp_cache_gc');
|
544 |
+
}
|
545 |
}
|
546 |
}
|
547 |
|
579 |
}
|
580 |
}
|
581 |
|
582 |
+
function wp_cache_post_id_gc( $siteurl, $post_id ) {
|
583 |
+
global $cache_path;
|
584 |
+
|
585 |
+
$post_id = intval( $post_id );
|
586 |
+
if( $post_id == 0 )
|
587 |
+
return;
|
588 |
+
|
589 |
+
$permalink = trailingslashit( str_replace( get_option( 'home' ), '', post_permalink( $post_id ) ) );
|
590 |
+
$dir = $cache_path . 'supercache/' . $siteurl;
|
591 |
+
prune_super_cache( $dir . $permalink, true, true );
|
592 |
+
@rmdir( $dir . $permalink );
|
593 |
+
prune_super_cache( $dir . 'page/', true );
|
594 |
+
}
|
595 |
+
|
596 |
function wp_cache_post_change($post_id) {
|
597 |
global $file_prefix, $cache_path, $blog_id, $blogcacheid, $super_cache_enabled;
|
598 |
static $last_processed = -1;
|
608 |
// make sure the front page has a rebuild file
|
609 |
prune_super_cache( $cache_path . 'supercache/' . $siteurl . 'index.html', true, true );
|
610 |
prune_super_cache( $cache_path . 'supercache/' . $siteurl . 'index.html.gz', true, true );
|
611 |
+
wp_cache_post_id_gc( $siteurl, $post_id );
|
612 |
+
if( get_option( 'show_on_front' ) == 'page' ) {
|
613 |
+
wp_cache_post_id_gc( $siteurl, get_option( 'page_on_front' ) );
|
614 |
+
wp_cache_post_id_gc( $siteurl, get_option( 'page_for_posts' ) );
|
|
|
|
|
615 |
}
|
616 |
}
|
617 |
|
|
|
618 |
$matches = array();
|
619 |
if ( ($handle = opendir( $cache_path . 'meta/' )) ) {
|
620 |
while ( false !== ($file = readdir($handle))) {
|
622 |
$meta_pathname = $cache_path . 'meta/' . $file;
|
623 |
$content_pathname = $cache_path . $matches[1] . ".html";
|
624 |
$meta = unserialize(@file_get_contents($meta_pathname));
|
625 |
+
if( false == is_array( $meta ) )
|
626 |
+
continue;
|
627 |
if ($post_id > 0 && $meta) {
|
628 |
+
if ($meta[ 'blog_id' ] == $blog_id && (!$meta[ 'post' ] || $meta[ 'post' ] == $post_id) ) {
|
629 |
@unlink($meta_pathname);
|
630 |
@unlink($content_pathname);
|
631 |
+
@unlink($cache_path . 'supercache/' . trailingslashit( $meta[ 'uri' ] ) . 'index.html');
|
632 |
+
@unlink($cache_path . 'supercache/' . trailingslashit( $meta[ 'uri' ] ) . 'index.html.gz');
|
633 |
}
|
634 |
+
} elseif ($meta[ 'blog_id' ] == $blog_id) {
|
635 |
@unlink($meta_pathname);
|
636 |
@unlink($content_pathname);
|
637 |
+
@unlink($cache_path . 'supercache/' . trailingslashit( $meta[ 'uri' ] ) . 'index.html');
|
638 |
+
@unlink($cache_path . 'supercache/' . trailingslashit( $meta[ 'uri' ] ) . 'index.html.gz');
|
639 |
}
|
640 |
|
641 |
}
|
wp-cache.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WP Super Cache
|
4 |
Plugin URI: http://ocaoimh.ie/wp-super-cache/
|
5 |
Description: Very fast caching plugin for WordPress.
|
6 |
-
Version: 0.9.
|
7 |
Author: Donncha O Caoimh
|
8 |
Author URI: http://ocaoimh.ie/
|
9 |
*/
|
@@ -320,7 +320,7 @@ jQuery(document).ready(function(){
|
|
320 |
<p><label><input type='checkbox' name='wp_cache_hello_world' <?php if( $wp_cache_hello_world ) echo "checked"; ?> value='1'> Proudly tell the world your server is Digg proof! (places a message in your blog's footer)</label></p>
|
321 |
<p><label><input type='checkbox' name='wp_cache_clear_on_post_edit' <?php if( $wp_cache_clear_on_post_edit ) echo "checked"; ?> value='1'> Clear all cache files when a post or page is published. (This may significantly slow down saving of posts.)</label></p>
|
322 |
<p><label><input type='checkbox' name='cache_rebuild_files' <?php if( $cache_rebuild_files ) echo "checked"; ?> value='1'> Enable the "cache rebuild" feature. Serve a supercache file to anonymous users while a new file is being generated. Recommended for <em>very</em> busy websites with lots of comments. Makes "directly cached pages" and "Lockdown mode" obsolete.</label></p>
|
323 |
-
<p><label><input type='checkbox' name='wp_cache_mutex_disabled' <?php if( $wp_cache_mutex_disabled ) echo "checked"; ?> value='1'> Disable file locking. If you experience problems with mutex or file locks this
|
324 |
<p><label><input type='checkbox' name='wp_cache_mobile_enabled' <?php if( $wp_cache_mobile_enabled ) echo "checked"; ?> value='1'> Mobile device support. Plugin will enter "Half-On" mode.</label></p>
|
325 |
<p><strong>Note:</strong> If uninstalling this plugin, make sure the directory <em><?php echo WP_CONTENT_DIR; ?></em> is writeable by the webserver so the files <em>advanced-cache.php</em> and <em>cache-config.php</em> can be deleted automatically. (Making sure those files are writeable too is probably a good idea!)</p>
|
326 |
<?php
|
@@ -329,7 +329,7 @@ jQuery(document).ready(function(){
|
|
329 |
?>
|
330 |
</form>
|
331 |
<?php
|
332 |
-
if( function_exists( 'apache_get_modules' ) ) {
|
333 |
$mods = apache_get_modules();
|
334 |
$required_modules = array( 'mod_mime' => 'Required to serve compressed supercache files properly.', 'mod_headers' => 'Required to set caching information on supercache pages. IE7 users will see old pages without this module.', 'mod_expires' => 'Set the expiry date on supercached pages. Visitors may not see new pages when they refresh or leave comments without this module.' );
|
335 |
foreach( $required_modules as $req => $desc ) {
|
@@ -339,7 +339,7 @@ jQuery(document).ready(function(){
|
|
339 |
}
|
340 |
if( is_array( $missing_mods ) ) {
|
341 |
echo "<h3>Missing Apache Modules</h3>";
|
342 |
-
echo "<p>The following Apache modules are missing. The plugin will work without them
|
343 |
echo "<ul>";
|
344 |
foreach( $missing_mods as $req => $desc ) {
|
345 |
echo "<li> $req - $desc</li>";
|
@@ -1146,6 +1146,7 @@ function wp_cache_files() {
|
|
1146 |
$this_expired = true;
|
1147 |
}
|
1148 |
$count++;
|
|
|
1149 |
if ($list_files) {
|
1150 |
$meta = new CacheMeta;
|
1151 |
$meta = unserialize(file_get_contents($cache_path . 'meta/' . $file));
|
@@ -1163,6 +1164,7 @@ function wp_cache_files() {
|
|
1163 |
wp_nonce_field('wp-cache');
|
1164 |
echo "</form></td></tr>\n";
|
1165 |
}
|
|
|
1166 |
}
|
1167 |
}
|
1168 |
closedir($handle);
|
@@ -1309,8 +1311,8 @@ function wp_cache_clean_expired($file_prefix) {
|
|
1309 |
while ( false !== ($file = readdir($handle))) {
|
1310 |
if ( preg_match($expr, $file) &&
|
1311 |
(filemtime($cache_path . $file) + $cache_max_time) <= $now) {
|
1312 |
-
unlink($cache_path . $file);
|
1313 |
-
unlink($cache_path . 'meta/' . str_replace( '.html', '.meta', $file ) );
|
1314 |
}
|
1315 |
}
|
1316 |
closedir($handle);
|
@@ -1382,17 +1384,24 @@ add_filter( 'favorite_actions', 'wp_cache_favorite_action' );
|
|
1382 |
|
1383 |
function wp_cache_plugin_notice( $plugin ) {
|
1384 |
global $cache_enabled;
|
1385 |
-
if( $plugin == 'wp-super-cache/wp-cache.php' )
|
1386 |
-
if( !$cache_enabled )
|
1387 |
echo '<td colspan="5" class="plugin-update">WP Super Cache must be configured. Go to <a href="' . admin_url( 'options-general.php?page=wpsupercache' ) . '">the admin page</a> to enable and configure the plugin.</td>';
|
1388 |
-
}
|
1389 |
}
|
1390 |
add_action( 'after_plugin_row', 'wp_cache_plugin_notice' );
|
1391 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1392 |
function wp_cache_admin_notice() {
|
1393 |
global $cache_enabled;
|
1394 |
if( substr( $_SERVER["PHP_SELF"], -11 ) == 'plugins.php' && !$cache_enabled )
|
1395 |
-
|
1396 |
}
|
1397 |
-
add_action( '
|
1398 |
?>
|
3 |
Plugin Name: WP Super Cache
|
4 |
Plugin URI: http://ocaoimh.ie/wp-super-cache/
|
5 |
Description: Very fast caching plugin for WordPress.
|
6 |
+
Version: 0.9.2
|
7 |
Author: Donncha O Caoimh
|
8 |
Author URI: http://ocaoimh.ie/
|
9 |
*/
|
320 |
<p><label><input type='checkbox' name='wp_cache_hello_world' <?php if( $wp_cache_hello_world ) echo "checked"; ?> value='1'> Proudly tell the world your server is Digg proof! (places a message in your blog's footer)</label></p>
|
321 |
<p><label><input type='checkbox' name='wp_cache_clear_on_post_edit' <?php if( $wp_cache_clear_on_post_edit ) echo "checked"; ?> value='1'> Clear all cache files when a post or page is published. (This may significantly slow down saving of posts.)</label></p>
|
322 |
<p><label><input type='checkbox' name='cache_rebuild_files' <?php if( $cache_rebuild_files ) echo "checked"; ?> value='1'> Enable the "cache rebuild" feature. Serve a supercache file to anonymous users while a new file is being generated. Recommended for <em>very</em> busy websites with lots of comments. Makes "directly cached pages" and "Lockdown mode" obsolete.</label></p>
|
323 |
+
<p><label><input type='checkbox' name='wp_cache_mutex_disabled' <?php if( $wp_cache_mutex_disabled ) echo "checked"; ?> value='1'> Disable file locking. If you experience problems with mutex or file locks this will help but may cause increased server load.</label></p>
|
324 |
<p><label><input type='checkbox' name='wp_cache_mobile_enabled' <?php if( $wp_cache_mobile_enabled ) echo "checked"; ?> value='1'> Mobile device support. Plugin will enter "Half-On" mode.</label></p>
|
325 |
<p><strong>Note:</strong> If uninstalling this plugin, make sure the directory <em><?php echo WP_CONTENT_DIR; ?></em> is writeable by the webserver so the files <em>advanced-cache.php</em> and <em>cache-config.php</em> can be deleted automatically. (Making sure those files are writeable too is probably a good idea!)</p>
|
326 |
<?php
|
329 |
?>
|
330 |
</form>
|
331 |
<?php
|
332 |
+
if( $super_cache_enabled && function_exists( 'apache_get_modules' ) ) {
|
333 |
$mods = apache_get_modules();
|
334 |
$required_modules = array( 'mod_mime' => 'Required to serve compressed supercache files properly.', 'mod_headers' => 'Required to set caching information on supercache pages. IE7 users will see old pages without this module.', 'mod_expires' => 'Set the expiry date on supercached pages. Visitors may not see new pages when they refresh or leave comments without this module.' );
|
335 |
foreach( $required_modules as $req => $desc ) {
|
339 |
}
|
340 |
if( is_array( $missing_mods ) ) {
|
341 |
echo "<h3>Missing Apache Modules</h3>";
|
342 |
+
echo "<p>The following Apache modules are missing. The plugin will work in half-on mode without them. In full Supercache mode, your visitors may see corrupted pages or out of date content however.</p>";
|
343 |
echo "<ul>";
|
344 |
foreach( $missing_mods as $req => $desc ) {
|
345 |
echo "<li> $req - $desc</li>";
|
1146 |
$this_expired = true;
|
1147 |
}
|
1148 |
$count++;
|
1149 |
+
/*
|
1150 |
if ($list_files) {
|
1151 |
$meta = new CacheMeta;
|
1152 |
$meta = unserialize(file_get_contents($cache_path . 'meta/' . $file));
|
1164 |
wp_nonce_field('wp-cache');
|
1165 |
echo "</form></td></tr>\n";
|
1166 |
}
|
1167 |
+
*/
|
1168 |
}
|
1169 |
}
|
1170 |
closedir($handle);
|
1311 |
while ( false !== ($file = readdir($handle))) {
|
1312 |
if ( preg_match($expr, $file) &&
|
1313 |
(filemtime($cache_path . $file) + $cache_max_time) <= $now) {
|
1314 |
+
@unlink($cache_path . $file);
|
1315 |
+
@unlink($cache_path . 'meta/' . str_replace( '.html', '.meta', $file ) );
|
1316 |
}
|
1317 |
}
|
1318 |
closedir($handle);
|
1384 |
|
1385 |
function wp_cache_plugin_notice( $plugin ) {
|
1386 |
global $cache_enabled;
|
1387 |
+
if( $plugin == 'wp-super-cache/wp-cache.php' && !$cache_enabled )
|
|
|
1388 |
echo '<td colspan="5" class="plugin-update">WP Super Cache must be configured. Go to <a href="' . admin_url( 'options-general.php?page=wpsupercache' ) . '">the admin page</a> to enable and configure the plugin.</td>';
|
|
|
1389 |
}
|
1390 |
add_action( 'after_plugin_row', 'wp_cache_plugin_notice' );
|
1391 |
|
1392 |
+
function wp_cache_plugin_actions( $links, $file ) {
|
1393 |
+
if( $file == 'wp-super-cache/wp-cache.php' ) {
|
1394 |
+
$settings_link = '<a href="' . admin_url( 'options-general.php?page=wpsupercache' ) . '">' . __('Settings') . '</a>';
|
1395 |
+
array_unshift( $links, $settings_link ); // before other links
|
1396 |
+
}
|
1397 |
+
return $links;
|
1398 |
+
}
|
1399 |
+
add_filter( 'plugin_action_links', 'wp_cache_plugin_actions', 10, 2 );
|
1400 |
+
|
1401 |
function wp_cache_admin_notice() {
|
1402 |
global $cache_enabled;
|
1403 |
if( substr( $_SERVER["PHP_SELF"], -11 ) == 'plugins.php' && !$cache_enabled )
|
1404 |
+
echo '<div class="error"><p><strong>' . sprintf( __('WP Super Cache is disabled. Please go to the <a href="%s">plugin admin page</a> to enable caching.' ), admin_url( 'options-general.php?page=wpsupercache' ) ) . '</strong></p></div>';
|
1405 |
}
|
1406 |
+
add_action( 'admin_notices', 'wp_cache_admin_notice' );
|
1407 |
?>
|