Version Description
Download this release
Release Info
Developer | donncha |
Plugin | WP Super Cache |
Version | 0.9 |
Comparing to | |
See all releases |
Code changes from version 0.8.9 to 0.9
- Changelog.txt +82 -0
- advanced-cache.php +2 -6
- readme.txt +13 -1
- wp-cache-config-sample.php +5 -0
- wp-cache-phase1.php +27 -0
- wp-cache-phase2.php +53 -28
- wp-cache.php +53 -13
Changelog.txt
CHANGED
@@ -1,3 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
2009-01-23 19:09 donncha
|
2 |
|
3 |
* readme.txt, wp-cache.php: Bump version number to 0.8.9 and update
|
1 |
+
2009-01-27 06:17 donncha
|
2 |
+
|
3 |
+
* readme.txt, wp-cache.php: Bump version to 0.9
|
4 |
+
|
5 |
+
2009-01-27 06:17 donncha
|
6 |
+
|
7 |
+
* wp-cache-phase2.php: Bring back mfunc code
|
8 |
+
|
9 |
+
2009-01-27 05:53 donncha
|
10 |
+
|
11 |
+
* wp-cache-phase2.php, wp-cache.php: Set GC to 10 minutes instead
|
12 |
+
of 30.
|
13 |
+
|
14 |
+
2009-01-26 20:08 donncha
|
15 |
+
|
16 |
+
* wp-cache.php: Show last and next garbage collection times
|
17 |
+
|
18 |
+
2009-01-26 18:11 donncha
|
19 |
+
|
20 |
+
* wp-cache.php: Make sure constant value is displayed, props
|
21 |
+
Jonathan Dingman
|
22 |
+
|
23 |
+
2009-01-26 17:32 donncha
|
24 |
+
|
25 |
+
* wp-cache-phase1.php: Update mobile "enabled" variable
|
26 |
+
|
27 |
+
2009-01-26 17:32 donncha
|
28 |
+
|
29 |
+
* wp-cache-phase2.php: Don't send gzip headers if headers already
|
30 |
+
sent
|
31 |
+
|
32 |
+
2009-01-26 13:00 donncha
|
33 |
+
|
34 |
+
* wp-cache-config-sample.php, wp-cache-phase2.php, wp-cache.php:
|
35 |
+
Removed "dynamic caching" that isn't documented anywhere any more
|
36 |
+
Fixed activate bugs with mobile device support
|
37 |
+
|
38 |
+
2009-01-26 11:12 donncha
|
39 |
+
|
40 |
+
* wp-cache-config-sample.php, wp-cache-phase1.php, wp-cache.php:
|
41 |
+
Mobile device support via
|
42 |
+
http://wordpress.org/extend/plugins/wordpress-mobile-edition/ by
|
43 |
+
Alex King
|
44 |
+
|
45 |
+
2009-01-26 10:03 donncha
|
46 |
+
|
47 |
+
* readme.txt: Added extra FAQs
|
48 |
+
|
49 |
+
2009-01-25 11:21 donncha
|
50 |
+
|
51 |
+
* wp-cache-phase2.php, wp-cache.php: Admin page updates
|
52 |
+
If expiry time is over 30 minutes, set garbage collection to 30
|
53 |
+
minutes, else expiry time
|
54 |
+
|
55 |
+
2009-01-25 09:11 donncha
|
56 |
+
|
57 |
+
* wp-cache-phase2.php: If supercache enabled, Don't create wp-cache
|
58 |
+
files for anonymous users. Should cut down cached files by half
|
59 |
+
ore more.
|
60 |
+
|
61 |
+
2009-01-25 07:56 donncha
|
62 |
+
|
63 |
+
* wp-cache-phase2.php: Warn if cache expiry cron job took longer
|
64 |
+
than 30 seconds, props SiriusBuzz
|
65 |
+
|
66 |
+
2009-01-25 07:49 donncha
|
67 |
+
|
68 |
+
* advanced-cache.php, wp-cache-phase2.php, wp-cache.php:
|
69 |
+
advanced-cache.php will load the phase1.php even in relocated
|
70 |
+
plugin folders now. (NOTE. Must be updated if plugin folder
|
71 |
+
changes)
|
72 |
+
Removed error_log()
|
73 |
+
|
74 |
+
2009-01-24 06:03 donncha
|
75 |
+
|
76 |
+
* wp-cache.php: Update advanced-cache.php message, props Jonathan
|
77 |
+
Dingman
|
78 |
+
|
79 |
+
2009-01-23 19:10 donncha
|
80 |
+
|
81 |
+
* Changelog.txt: Updated Changelog for 0.8.9
|
82 |
+
|
83 |
2009-01-23 19:09 donncha
|
84 |
|
85 |
* readme.txt, wp-cache.php: Bump version number to 0.8.9 and update
|
advanced-cache.php
CHANGED
@@ -1,8 +1,4 @@
|
|
1 |
<?php
|
2 |
-
# WP SUPER CACHE 0.8.9
|
3 |
-
|
4 |
-
require_once( constant( 'WP_PLUGIN_DIR' ) . '/wp-super-cache/wp-cache-phase1.php' );
|
5 |
-
} else {
|
6 |
-
require_once( 'plugins/wp-super-cache/wp-cache-phase1.php' );
|
7 |
-
}
|
8 |
?>
|
1 |
<?php
|
2 |
+
# WP SUPER CACHE 0.8.9.1
|
3 |
+
require_once( 'CACHEHOME' . 'wp-cache-phase1.php' );
|
|
|
|
|
|
|
|
|
4 |
?>
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: donncha
|
3 |
Tags: performance,caching,wp-cache,wp-super-cache
|
4 |
Tested up to: 2.7
|
5 |
-
Stable tag: 0.
|
6 |
Requires at least: 2.2
|
7 |
|
8 |
A very fast caching engine for WordPress that produces static html files.
|
@@ -99,6 +99,18 @@ Comments will show as soon as they are moderated, depending on the comment polic
|
|
99 |
|
100 |
No, it will do the opposite in fact. Super Cache files are compressed and stored that way so the heavy compression is done only once. These files are generally much smaller and are sent to a visitor's browser much more quickly than uncompressed html. As a result, your server spends less time talking over the network which saves CPU time and bandwidth, and can also serve the next request much more quickly.
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
= How do I uninstall WP Super Cache? =
|
103 |
|
104 |
1. Clear the cache in the backend page and then deactivate it on the plugins page.
|
2 |
Contributors: donncha
|
3 |
Tags: performance,caching,wp-cache,wp-super-cache
|
4 |
Tested up to: 2.7
|
5 |
+
Stable tag: 0.9
|
6 |
Requires at least: 2.2
|
7 |
|
8 |
A very fast caching engine for WordPress that produces static html files.
|
99 |
|
100 |
No, it will do the opposite in fact. Super Cache files are compressed and stored that way so the heavy compression is done only once. These files are generally much smaller and are sent to a visitor's browser much more quickly than uncompressed html. As a result, your server spends less time talking over the network which saves CPU time and bandwidth, and can also serve the next request much more quickly.
|
101 |
|
102 |
+
= Why doesn't Popularity Contest, WP Postratings or plugin X not work or update on my blog now? =
|
103 |
+
|
104 |
+
This plugin caches entire pages and some plugins expect they can run PHP code every time a page loads. To fix this, the plugin needs to use Javascript or AJAX methods to update. If the plugin displays information on the page, that must be a Javascript request too.
|
105 |
+
|
106 |
+
= Why doesn't the plugin cache requests by search engine bots by default? =
|
107 |
+
|
108 |
+
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.
|
109 |
+
|
110 |
+
= Why can't I create a cache file of every page on my site? =
|
111 |
+
|
112 |
+
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?
|
113 |
+
|
114 |
= How do I uninstall WP Super Cache? =
|
115 |
|
116 |
1. Clear the cache in the backend page and then deactivate it on the plugins page.
|
wp-cache-config-sample.php
CHANGED
@@ -63,4 +63,9 @@ if ( '/' != substr($cache_path, -1)) {
|
|
63 |
$cache_path .= '/';
|
64 |
}
|
65 |
|
|
|
|
|
|
|
|
|
|
|
66 |
?>
|
63 |
$cache_path .= '/';
|
64 |
}
|
65 |
|
66 |
+
$wp_cache_mobile = 0;
|
67 |
+
$wp_cache_mobile_whitelist = 'Stand Alone/QNws';
|
68 |
+
$wp_cache_mobile_browsers = '2.0 MMP, 240x320, AvantGo, BlackBerry, Blazer, Cellphone, Danger, DoCoMo, Elaine/3.0, EudoraWeb, hiptop, IEMobile, iPhone, iPod, KYOCERA/WX310K, LG/U990, MIDP-2.0, MMEF20, MOT-V, NetFront, Newt, Nintendo Wii, Nitro, Nokia, Opera Mini, Palm, Playstation Portable, portalmmm, Proxinet, ProxiNet, SHARP-TQ-GX10, Small, SonyEricsson, Symbian OS, SymbianOS, TS21i-10, UP.Browser, UP.Link, Windows CE, WinWAP';
|
69 |
+
|
70 |
+
$wp_cache_gzip_first = 0;
|
71 |
?>
|
wp-cache-phase1.php
CHANGED
@@ -51,6 +51,8 @@ if ($cache_compression) {
|
|
51 |
$wp_cache_gzip_encoding = gzip_accepted();
|
52 |
}
|
53 |
|
|
|
|
|
54 |
$key = $blogcacheid . md5( do_cacheaction( 'wp_cache_key', $_SERVER['HTTP_HOST'].preg_replace('/#.*$/', '', str_replace( '/index.php', '/', $_SERVER['REQUEST_URI'] ) ).$wp_cache_gzip_encoding.wp_cache_get_cookies_values() ) );
|
55 |
|
56 |
$cache_filename = $file_prefix . $key . '.html';
|
@@ -131,6 +133,31 @@ function do_cacheaction( $action, $value = '' ) {
|
|
131 |
return $value;
|
132 |
}
|
133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
function wp_cache_debug( $message ) {
|
135 |
global $wp_cache_debug;
|
136 |
if( !isset( $wp_cache_debug ) )
|
51 |
$wp_cache_gzip_encoding = gzip_accepted();
|
52 |
}
|
53 |
|
54 |
+
add_cacheaction( 'wp_cache_key', 'wp_cache_check_mobile' );
|
55 |
+
|
56 |
$key = $blogcacheid . md5( do_cacheaction( 'wp_cache_key', $_SERVER['HTTP_HOST'].preg_replace('/#.*$/', '', str_replace( '/index.php', '/', $_SERVER['REQUEST_URI'] ) ).$wp_cache_gzip_encoding.wp_cache_get_cookies_values() ) );
|
57 |
|
58 |
$cache_filename = $file_prefix . $key . '.html';
|
133 |
return $value;
|
134 |
}
|
135 |
|
136 |
+
// From http://wordpress.org/extend/plugins/wordpress-mobile-edition/ by Alex King
|
137 |
+
function wp_cache_check_mobile( $cache_key ) {
|
138 |
+
global $wp_cache_mobile_enabled, $wp_cache_mobile_browser, $wp_cache_mobile_browsers;
|
139 |
+
if( !isset( $wp_cache_mobile_enabled ) || false == $wp_cache_mobile_enabled )
|
140 |
+
return $cache_key;
|
141 |
+
|
142 |
+
if (!isset($_SERVER["HTTP_USER_AGENT"])) {
|
143 |
+
return $cache_key;
|
144 |
+
}
|
145 |
+
$whitelist = explode( ',', $wp_cache_mobile_whitelist );
|
146 |
+
foreach ($whitelist as $browser) {
|
147 |
+
if (strstr($_SERVER["HTTP_USER_AGENT"], trim($browser))) {
|
148 |
+
return $cache_key;
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
$browsers = explode( ',', $wp_cache_mobile_browsers );
|
153 |
+
foreach ($browsers as $browser) {
|
154 |
+
if (strstr($_SERVER["HTTP_USER_AGENT"], trim( $browser ))) {
|
155 |
+
return $cache_key . $browser;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
return $cache_key;
|
159 |
+
}
|
160 |
+
|
161 |
function wp_cache_debug( $message ) {
|
162 |
global $wp_cache_debug;
|
163 |
if( !isset( $wp_cache_debug ) )
|
wp-cache-phase2.php
CHANGED
@@ -172,7 +172,7 @@ function wp_cache_ob_callback($buffer) {
|
|
172 |
global $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
|
173 |
global $new_cache, $wp_cache_meta_object, $file_expired, $blog_id, $cache_compression;
|
174 |
global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
|
175 |
-
global $wp_cache_404, $gzsize;
|
176 |
|
177 |
$new_cache = true;
|
178 |
|
@@ -213,10 +213,18 @@ function wp_cache_ob_callback($buffer) {
|
|
213 |
$super_cache_enabled = false;
|
214 |
|
215 |
$tmp_wpcache_filename = $cache_path . uniqid( mt_rand(), true ) . '.tmp';
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
}
|
221 |
if( $super_cache_enabled ) {
|
222 |
if( @is_dir( $dir ) == false )
|
@@ -230,18 +238,18 @@ function wp_cache_ob_callback($buffer) {
|
|
230 |
$fr2 = @fopen( $tmp_cache_filename, 'w' );
|
231 |
if (!$fr2) {
|
232 |
$buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) . " -->\n";
|
233 |
-
fclose( $fr );
|
234 |
-
|
235 |
return $buffer;
|
236 |
}
|
237 |
if( $cache_compression ) {
|
238 |
$gz = @fopen( $tmp_cache_filename . ".gz", 'w');
|
239 |
if (!$gz) {
|
240 |
$buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) . ".gz -->\n";
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
return $buffer;
|
246 |
}
|
247 |
}
|
@@ -258,7 +266,8 @@ function wp_cache_ob_callback($buffer) {
|
|
258 |
/* Clean function calls in tag */
|
259 |
$buffer = preg_replace('|<!--mclude (.*?)-->|is', '<!--mclude-->', $buffer);
|
260 |
$buffer = preg_replace('|<!--mfunc (.*?)-->|is', '<!--mfunc-->', $buffer);
|
261 |
-
|
|
|
262 |
if( $fr2 )
|
263 |
fputs($fr2, $store . '<!-- super cache -->' );
|
264 |
if( $gz )
|
@@ -274,12 +283,14 @@ function wp_cache_ob_callback($buffer) {
|
|
274 |
if ($wp_cache_gzip_encoding) {
|
275 |
array_push($wp_cache_meta_object->headers, 'Content-Encoding: ' . $wp_cache_gzip_encoding);
|
276 |
array_push($wp_cache_meta_object->headers, 'Vary: Accept-Encoding, Cookie');
|
277 |
-
array_push($wp_cache_meta_object->headers, 'Content-Length: ' .
|
278 |
// Return uncompressed data & store compressed for later use
|
279 |
-
|
|
|
280 |
} else { // no compression
|
281 |
array_push($wp_cache_meta_object->headers, 'Vary: Cookie');
|
282 |
-
|
|
|
283 |
}
|
284 |
if( $fr2 )
|
285 |
fputs($fr2, $buffer . $log . '<!-- super cache -->' );
|
@@ -288,28 +299,37 @@ function wp_cache_ob_callback($buffer) {
|
|
288 |
$buffer .= $log;
|
289 |
}
|
290 |
$new_cache = true;
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
|
|
|
|
295 |
}
|
296 |
if( $fr2 ) {
|
297 |
fclose($fr2);
|
298 |
if( !@rename( $tmp_cache_filename, $cache_fname ) ) {
|
299 |
-
unlink( $cache_fname );
|
300 |
-
rename( $tmp_cache_filename, $cache_fname );
|
301 |
}
|
302 |
}
|
303 |
if( $gz ) {
|
304 |
fclose($gz);
|
305 |
if( !@rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' ) ) {
|
306 |
-
unlink( $cache_fname . '.gz' );
|
307 |
-
rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' );
|
308 |
}
|
309 |
}
|
310 |
}
|
311 |
wp_cache_writers_exit();
|
312 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
}
|
314 |
|
315 |
function wp_cache_phase2_clean_cache($file_prefix) {
|
@@ -456,7 +476,9 @@ function wp_cache_phase2_clean_expired($file_prefix) {
|
|
456 |
}
|
457 |
|
458 |
function wp_cache_shutdown_callback() {
|
459 |
-
global $cache_path, $cache_max_time, $file_expired, $file_prefix, $meta_file, $new_cache, $wp_cache_meta_object, $known_headers, $blog_id, $wp_cache_gzip_encoding, $gzsize, $cache_filename;
|
|
|
|
|
460 |
|
461 |
$wp_cache_meta_object->uri = $_SERVER["SERVER_NAME"].preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI']); // To avoid XSS attacs
|
462 |
$wp_cache_meta_object->blog_id=$blog_id;
|
@@ -514,7 +536,7 @@ function wp_cache_shutdown_callback() {
|
|
514 |
|
515 |
@ob_end_flush();
|
516 |
flush(); //Ensure we send data to the client
|
517 |
-
if ($new_cache) {
|
518 |
if( $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $wp_cache_meta_object->headers ) ) {
|
519 |
array_push($wp_cache_meta_object->headers, 'Content-Encoding: ' . $wp_cache_gzip_encoding);
|
520 |
array_push($wp_cache_meta_object->headers, 'Vary: Accept-Encoding, Cookie');
|
@@ -548,7 +570,8 @@ function wp_cache_shutdown_callback() {
|
|
548 |
return;
|
549 |
}
|
550 |
|
551 |
-
|
|
|
552 |
return;
|
553 |
update_option( 'wpsupercache_gc_time', time() );
|
554 |
|
@@ -665,15 +688,17 @@ function wp_cache_post_id() {
|
|
665 |
|
666 |
function wp_cache_gc_cron() {
|
667 |
global $file_prefix, $cache_max_time;
|
668 |
-
error_log( date( "H:i:s" ) . " wp_cache_gc_cron\n", 3, "/tmp/log.txt" );
|
669 |
|
670 |
if( !isset( $cache_max_time ) )
|
671 |
$cache_max_time = 600;
|
672 |
|
|
|
673 |
if( !wp_cache_phase2_clean_expired($file_prefix ) ) {
|
674 |
wp_cache_debug( 'Cache Expiry cron job failed. Probably mutex locked.' );
|
675 |
update_option( 'wpsupercache_gc_time', time() - ( $cache_max_time - 10 ) ); // if GC failed then run it again in one minute
|
676 |
}
|
|
|
|
|
677 |
}
|
678 |
|
679 |
?>
|
172 |
global $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
|
173 |
global $new_cache, $wp_cache_meta_object, $file_expired, $blog_id, $cache_compression;
|
174 |
global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
|
175 |
+
global $wp_cache_404, $gzsize, $supercacheonly, $wp_cache_gzip_first;
|
176 |
|
177 |
$new_cache = true;
|
178 |
|
213 |
$super_cache_enabled = false;
|
214 |
|
215 |
$tmp_wpcache_filename = $cache_path . uniqid( mt_rand(), true ) . '.tmp';
|
216 |
+
|
217 |
+
// Don't create wp-cache files for anon users
|
218 |
+
$supercacheonly = false;
|
219 |
+
if( $super_cache_enabled && wp_cache_get_cookies_values() == '' )
|
220 |
+
$supercacheonly = true;
|
221 |
+
|
222 |
+
if( !$supercacheonly ) {
|
223 |
+
$fr = @fopen($tmp_wpcache_filename, 'w');
|
224 |
+
if (!$fr) {
|
225 |
+
$buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $cache_path ) . $cache_filename . " -->\n";
|
226 |
+
return $buffer;
|
227 |
+
}
|
228 |
}
|
229 |
if( $super_cache_enabled ) {
|
230 |
if( @is_dir( $dir ) == false )
|
238 |
$fr2 = @fopen( $tmp_cache_filename, 'w' );
|
239 |
if (!$fr2) {
|
240 |
$buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) . " -->\n";
|
241 |
+
@fclose( $fr );
|
242 |
+
@nlink( $tmp_wpcache_filename );
|
243 |
return $buffer;
|
244 |
}
|
245 |
if( $cache_compression ) {
|
246 |
$gz = @fopen( $tmp_cache_filename . ".gz", 'w');
|
247 |
if (!$gz) {
|
248 |
$buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace( ABSPATH, '', $tmp_cache_filename ) . ".gz -->\n";
|
249 |
+
@close( $fr );
|
250 |
+
@nlink( $tmp_wpcache_filename );
|
251 |
+
@close( $fr2 );
|
252 |
+
@nlink( $tmp_cache_filename );
|
253 |
return $buffer;
|
254 |
}
|
255 |
}
|
266 |
/* Clean function calls in tag */
|
267 |
$buffer = preg_replace('|<!--mclude (.*?)-->|is', '<!--mclude-->', $buffer);
|
268 |
$buffer = preg_replace('|<!--mfunc (.*?)-->|is', '<!--mfunc-->', $buffer);
|
269 |
+
if( $fr )
|
270 |
+
fputs($fr, $store);
|
271 |
if( $fr2 )
|
272 |
fputs($fr2, $store . '<!-- super cache -->' );
|
273 |
if( $gz )
|
283 |
if ($wp_cache_gzip_encoding) {
|
284 |
array_push($wp_cache_meta_object->headers, 'Content-Encoding: ' . $wp_cache_gzip_encoding);
|
285 |
array_push($wp_cache_meta_object->headers, 'Vary: Accept-Encoding, Cookie');
|
286 |
+
array_push($wp_cache_meta_object->headers, 'Content-Length: ' . $gzsize);
|
287 |
// Return uncompressed data & store compressed for later use
|
288 |
+
if( $fr )
|
289 |
+
fputs($fr, $gzdata);
|
290 |
} else { // no compression
|
291 |
array_push($wp_cache_meta_object->headers, 'Vary: Cookie');
|
292 |
+
if( $fr )
|
293 |
+
fputs($fr, $buffer.$log);
|
294 |
}
|
295 |
if( $fr2 )
|
296 |
fputs($fr2, $buffer . $log . '<!-- super cache -->' );
|
299 |
$buffer .= $log;
|
300 |
}
|
301 |
$new_cache = true;
|
302 |
+
if( $fr ) {
|
303 |
+
fclose($fr);
|
304 |
+
if( !@rename( $tmp_wpcache_filename, $cache_path . $cache_filename ) ) {
|
305 |
+
@unlink( $cache_path . $cache_filename );
|
306 |
+
@rename( $tmp_wpcache_filename, $cache_path . $cache_filename );
|
307 |
+
}
|
308 |
}
|
309 |
if( $fr2 ) {
|
310 |
fclose($fr2);
|
311 |
if( !@rename( $tmp_cache_filename, $cache_fname ) ) {
|
312 |
+
@unlink( $cache_fname );
|
313 |
+
@rename( $tmp_cache_filename, $cache_fname );
|
314 |
}
|
315 |
}
|
316 |
if( $gz ) {
|
317 |
fclose($gz);
|
318 |
if( !@rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' ) ) {
|
319 |
+
@unlink( $cache_fname . '.gz' );
|
320 |
+
@rename( $tmp_cache_filename . '.gz', $cache_fname . '.gz' );
|
321 |
}
|
322 |
}
|
323 |
}
|
324 |
wp_cache_writers_exit();
|
325 |
+
if ( !headers_sent() && isset( $wp_cache_gzip_first ) && 1 == $wp_cache_gzip_first && $wp_cache_gzip_encoding && $gzdata) {
|
326 |
+
header( 'Content-Encoding: ' . $wp_cache_gzip_encoding );
|
327 |
+
header( 'Vary: Accept-Encoding, Cookie' );
|
328 |
+
header( 'Content-Length: ' . $gzsize );
|
329 |
+
return $gzdata;
|
330 |
+
} else {
|
331 |
+
return $buffer;
|
332 |
+
}
|
333 |
}
|
334 |
|
335 |
function wp_cache_phase2_clean_cache($file_prefix) {
|
476 |
}
|
477 |
|
478 |
function wp_cache_shutdown_callback() {
|
479 |
+
global $cache_path, $cache_max_time, $file_expired, $file_prefix, $meta_file, $new_cache, $wp_cache_meta_object, $known_headers, $blog_id, $wp_cache_gzip_encoding, $gzsize, $cache_filename, $supercacheonly;
|
480 |
+
|
481 |
+
$supercacheonly = false;
|
482 |
|
483 |
$wp_cache_meta_object->uri = $_SERVER["SERVER_NAME"].preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI']); // To avoid XSS attacs
|
484 |
$wp_cache_meta_object->blog_id=$blog_id;
|
536 |
|
537 |
@ob_end_flush();
|
538 |
flush(); //Ensure we send data to the client
|
539 |
+
if ( ! $supercacheonly && $new_cache ) {
|
540 |
if( $wp_cache_gzip_encoding && !in_array( 'Content-Encoding: ' . $wp_cache_gzip_encoding, $wp_cache_meta_object->headers ) ) {
|
541 |
array_push($wp_cache_meta_object->headers, 'Content-Encoding: ' . $wp_cache_gzip_encoding);
|
542 |
array_push($wp_cache_meta_object->headers, 'Vary: Accept-Encoding, Cookie');
|
570 |
return;
|
571 |
}
|
572 |
|
573 |
+
$next_gc = $cache_max_time < 1800 ? $cache_max_time : 600;
|
574 |
+
if( $last_gc > ( time() - $next_gc ) )
|
575 |
return;
|
576 |
update_option( 'wpsupercache_gc_time', time() );
|
577 |
|
688 |
|
689 |
function wp_cache_gc_cron() {
|
690 |
global $file_prefix, $cache_max_time;
|
|
|
691 |
|
692 |
if( !isset( $cache_max_time ) )
|
693 |
$cache_max_time = 600;
|
694 |
|
695 |
+
$start = time();
|
696 |
if( !wp_cache_phase2_clean_expired($file_prefix ) ) {
|
697 |
wp_cache_debug( 'Cache Expiry cron job failed. Probably mutex locked.' );
|
698 |
update_option( 'wpsupercache_gc_time', time() - ( $cache_max_time - 10 ) ); // if GC failed then run it again in one minute
|
699 |
}
|
700 |
+
if( time() - $start > 30 )
|
701 |
+
wp_cache_debug( "Cache Expiry cron job took more than 30 seconds to execute.\nYou should reduce the Expiry Time in the WP Super Cache admin page\nas you probably have more cache files than your server can handle efficiently." );
|
702 |
}
|
703 |
|
704 |
?>
|
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 module for WordPress.
|
6 |
-
Version: 0.
|
7 |
Author: Donncha O Caoimh
|
8 |
Author URI: http://ocaoimh.ie/
|
9 |
*/
|
@@ -110,7 +110,7 @@ function wp_cache_add_pages() {
|
|
110 |
add_action('admin_menu', 'wp_cache_add_pages');
|
111 |
|
112 |
function wp_cache_manager() {
|
113 |
-
global $wp_cache_config_file, $valid_nonce, $supercachedir, $cache_path, $cache_enabled, $cache_compression, $super_cache_enabled, $wp_cache_hello_world, $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled;
|
114 |
|
115 |
if( function_exists( 'is_site_admin' ) )
|
116 |
if( !is_site_admin() )
|
@@ -210,6 +210,19 @@ jQuery(document).ready(function(){
|
|
210 |
|
211 |
if ( $valid_nonce ) {
|
212 |
if( isset( $_POST[ 'wp_cache_status' ] ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
switch( $_POST[ 'wp_cache_status' ] ) {
|
214 |
case 'all':
|
215 |
wp_cache_enable();
|
@@ -269,6 +282,7 @@ jQuery(document).ready(function(){
|
|
269 |
<h4>Experimental Features</h4>
|
270 |
<p><label><input type='checkbox' name='cache_rebuild_files' <?php if( $cache_rebuild_files ) echo "checked"; ?> value='1'> Enable experimental "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.</label></p>
|
271 |
<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 may help but may cause increased server load.</label></p>
|
|
|
272 |
<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>
|
273 |
<?php
|
274 |
echo "<div class='submit'><input type='submit' " . SUBMITDISABLED . " value='Update Status »' /></div>";
|
@@ -437,7 +451,7 @@ function wsc_mod_rewrite() {
|
|
437 |
}
|
438 |
echo " Make sure they appear before any existing WordPress rules.</p>";
|
439 |
echo "<pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p>";
|
440 |
-
echo "<p>Rules must be added to WP_CONTENT_DIR/cache/.htaccess too:</p>";
|
441 |
echo "<pre># BEGIN supercache\n" . wp_specialchars( $gziprules ) . "# END supercache</pre></p>";
|
442 |
if( !function_exists( 'is_site_admin' ) ) {
|
443 |
echo '<form name="updatehtaccess" action="'. $_SERVER["REQUEST_URI"] . '#modrewrite" method="post">';
|
@@ -676,8 +690,8 @@ function wp_cache_edit_max_time () {
|
|
676 |
echo '<form name="wp_edit_max_time" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
677 |
echo '<label for="wp_max_time">Expire time:</label> ';
|
678 |
echo "<input type=\"text\" size=6 name=\"wp_max_time\" value=\"$cache_max_time\" /> seconds";
|
679 |
-
echo "<h4>Garbage Collection</h4><p>
|
680 |
-
echo "<p>Checking for and deleting expired files is expensive, but it's expensive leaving them there too. On a very busy site you should set the expiry time to <em>300 seconds</em>. Experiment with different values and visit this page to see how many expired files remain at different times during the day.</p>";
|
681 |
echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="Change Expiration »" /></div>';
|
682 |
wp_nonce_field('wp-cache');
|
683 |
echo "</form>\n";
|
@@ -946,29 +960,48 @@ function wp_cache_verify_config_file() {
|
|
946 |
return true;
|
947 |
}
|
948 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
949 |
function wp_cache_check_link() {
|
950 |
global $wp_cache_link, $wp_cache_file;
|
951 |
|
952 |
$ret = true;
|
953 |
if( file_exists($wp_cache_link) ) {
|
954 |
$file = file_get_contents( $wp_cache_link );
|
955 |
-
if( strpos( $file, "WP SUPER CACHE 0.8.9" ) ) {
|
956 |
return true;
|
957 |
} else {
|
958 |
if( !@unlink($wp_cache_link) ) {
|
959 |
$ret = false;
|
960 |
-
}
|
961 |
-
$ret =
|
962 |
}
|
963 |
}
|
964 |
-
}
|
965 |
-
|
966 |
}
|
967 |
|
968 |
if( false == $ret ) {
|
969 |
-
echo "<
|
970 |
-
echo "
|
971 |
-
echo "or
|
|
|
|
|
|
|
972 |
return false;
|
973 |
}
|
974 |
return true;
|
@@ -1104,7 +1137,14 @@ function wp_cache_files() {
|
|
1104 |
$age = intval(($now - $sizes['ts'])/60);
|
1105 |
echo "<li>" . intval($sizes['expired']/2) . " Expired Pages</li></ul>";
|
1106 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1107 |
|
|
|
1108 |
echo '<form name="wp_cache_content_expired" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
1109 |
echo '<input type="hidden" name="wp_delete_expired" />';
|
1110 |
echo '<div class="submit" style="float:left"><input type="submit" ' . SUBMITDISABLED . 'value="Delete Expired »" /></div>';
|
3 |
Plugin Name: WP Super Cache
|
4 |
Plugin URI: http://ocaoimh.ie/wp-super-cache/
|
5 |
Description: Very fast caching module for WordPress.
|
6 |
+
Version: 0.9
|
7 |
Author: Donncha O Caoimh
|
8 |
Author URI: http://ocaoimh.ie/
|
9 |
*/
|
110 |
add_action('admin_menu', 'wp_cache_add_pages');
|
111 |
|
112 |
function wp_cache_manager() {
|
113 |
+
global $wp_cache_config_file, $valid_nonce, $supercachedir, $cache_path, $cache_enabled, $cache_compression, $super_cache_enabled, $wp_cache_hello_world, $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_mobile_enabled, $wp_cache_mobile_whitelist, $wp_cache_mobile_browsers;
|
114 |
|
115 |
if( function_exists( 'is_site_admin' ) )
|
116 |
if( !is_site_admin() )
|
210 |
|
211 |
if ( $valid_nonce ) {
|
212 |
if( isset( $_POST[ 'wp_cache_status' ] ) ) {
|
213 |
+
if( isset( $_POST[ 'wp_cache_mobile_enabled' ] ) ) {
|
214 |
+
$wp_cache_mobile_enabled = 1;
|
215 |
+
} else {
|
216 |
+
$wp_cache_mobile_enabled = 0;
|
217 |
+
}
|
218 |
+
if( $wp_cache_mobile_enabled == 1 ) {
|
219 |
+
if( !isset( $wp_cache_mobile_whitelist ) )
|
220 |
+
wp_cache_replace_line('^ *\$wp_cache_mobile_whitelist', "\$wp_cache_mobile_whitelist = 'Stand Alone/QNws';", $wp_cache_config_file);
|
221 |
+
if( false == isset( $wp_cache_mobile_browsers ) )
|
222 |
+
wp_cache_replace_line('^ *\$wp_cache_mobile_browsers', "\$wp_cache_mobile_browsers = '2.0 MMP, 240x320, AvantGo, BlackBerry, Blazer, Cellphone, Danger, DoCoMo, Elaine/3.0, EudoraWeb, hiptop, IEMobile, iPhone, iPod, KYOCERA/WX310K, LG/U990, MIDP-2.0, MMEF20, MOT-V, NetFront, Newt, Nintendo Wii, Nitro, Nokia, Opera Mini, Palm, Playstation Portable, portalmmm, Proxinet, ProxiNet, SHARP-TQ-GX10, Small, SonyEricsson, Symbian OS, SymbianOS, TS21i-10, UP.Browser, UP.Link, Windows CE, WinWAP';", $wp_cache_config_file);
|
223 |
+
$_POST[ 'wp_cache_status' ] = 'wpcache';
|
224 |
+
}
|
225 |
+
wp_cache_replace_line('^ *\$wp_cache_mobile_enabled', "\$wp_cache_mobile_enabled = " . $wp_cache_mobile_enabled . ";", $wp_cache_config_file);
|
226 |
switch( $_POST[ 'wp_cache_status' ] ) {
|
227 |
case 'all':
|
228 |
wp_cache_enable();
|
282 |
<h4>Experimental Features</h4>
|
283 |
<p><label><input type='checkbox' name='cache_rebuild_files' <?php if( $cache_rebuild_files ) echo "checked"; ?> value='1'> Enable experimental "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.</label></p>
|
284 |
<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 may help but may cause increased server load.</label></p>
|
285 |
+
<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>
|
286 |
<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>
|
287 |
<?php
|
288 |
echo "<div class='submit'><input type='submit' " . SUBMITDISABLED . " value='Update Status »' /></div>";
|
451 |
}
|
452 |
echo " Make sure they appear before any existing WordPress rules.</p>";
|
453 |
echo "<pre># BEGIN WPSuperCache\n" . wp_specialchars( $rules ) . "# END WPSuperCache</pre></p>";
|
454 |
+
echo "<p>Rules must be added to " . WP_CONTENT_DIR . "/cache/.htaccess too:</p>";
|
455 |
echo "<pre># BEGIN supercache\n" . wp_specialchars( $gziprules ) . "# END supercache</pre></p>";
|
456 |
if( !function_exists( 'is_site_admin' ) ) {
|
457 |
echo '<form name="updatehtaccess" action="'. $_SERVER["REQUEST_URI"] . '#modrewrite" method="post">';
|
690 |
echo '<form name="wp_edit_max_time" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
691 |
echo '<label for="wp_max_time">Expire time:</label> ';
|
692 |
echo "<input type=\"text\" size=6 name=\"wp_max_time\" value=\"$cache_max_time\" /> seconds";
|
693 |
+
echo "<h4>Garbage Collection</h4><p>If expiry time is more than 1800 seconds (half an hour), garbage collection will be done every 10 minutes, otherwise it will happen 10 seconds after the expiry time above.</p>";
|
694 |
+
echo "<p>Checking for and deleting expired files is expensive, but it's expensive leaving them there too. On a very busy site you should set the expiry time to <em>300 seconds</em>. Experiment with different values and visit this page to see how many expired files remain at different times during the day. Aim to have less than 500 cached files if possible.</p>";
|
695 |
echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="Change Expiration »" /></div>';
|
696 |
wp_nonce_field('wp-cache');
|
697 |
echo "</form>\n";
|
960 |
return true;
|
961 |
}
|
962 |
|
963 |
+
function wp_cache_create_advanced_cache() {
|
964 |
+
global $wp_cache_link, $wp_cache_file;
|
965 |
+
$ret = true;
|
966 |
+
|
967 |
+
$file = file_get_contents( $wp_cache_file );
|
968 |
+
$file = str_replace( 'CACHEHOME', constant( 'WPCACHEHOME' ), $file );
|
969 |
+
$fp = @fopen( $wp_cache_link, 'w' );
|
970 |
+
if( $fp ) {
|
971 |
+
fputs( $fp, $file );
|
972 |
+
fclose( $fp );
|
973 |
+
} else {
|
974 |
+
$ret = false;
|
975 |
+
}
|
976 |
+
return $ret;
|
977 |
+
}
|
978 |
+
|
979 |
function wp_cache_check_link() {
|
980 |
global $wp_cache_link, $wp_cache_file;
|
981 |
|
982 |
$ret = true;
|
983 |
if( file_exists($wp_cache_link) ) {
|
984 |
$file = file_get_contents( $wp_cache_link );
|
985 |
+
if( strpos( $file, "WP SUPER CACHE 0.8.9.1" ) ) {
|
986 |
return true;
|
987 |
} else {
|
988 |
if( !@unlink($wp_cache_link) ) {
|
989 |
$ret = false;
|
990 |
+
} else {
|
991 |
+
$ret = wp_cache_create_advanced_cache();
|
992 |
}
|
993 |
}
|
994 |
+
} else {
|
995 |
+
$ret = wp_cache_create_advanced_cache();
|
996 |
}
|
997 |
|
998 |
if( false == $ret ) {
|
999 |
+
echo "<h3>Warning! <em>" . constant( 'WP_CONTENT_DIR' ) . "/advanced-cache.php</em> does not exist or cannot be updated.</h3>";
|
1000 |
+
echo "<p><ul><li>1. If it already exists please delete the file first.</li>";
|
1001 |
+
echo "<li>2. Make " . constant( 'WP_CONTENT_DIR' ) . " writable using the chmod command through your ftp or server software. (<em>chmod 777 " . constant( 'WP_CONTENT_DIR' ) . "</em>) and refresh this page. This is only a temporary measure and you'll have to make it read only afterwards again. (Change 777 to 755 in the previous command)</li>";
|
1002 |
+
echo "<li>3. Refresh this page to update <em>" . constant( 'WP_CONTENT_DIR' ) . "/advanced-cache.php</em></li></ul>";
|
1003 |
+
echo "If that doesn't work, make sure the file <em>" . constant( 'WP_CONTENT_DIR' ) . "/advanced-cache.php</em> doesn't exist:<ol>";
|
1004 |
+
echo "<li>1. Open <em>$wp_cache_file</em> in a text editor.</li><li>2. Change the text <em>CACHEHOME</em> to <em>" . constant( 'WPCACHEHOME' ) . "</em></li><li>3. Save the file and copy it to <em>$wp_cache_link</em> and refresh this page.</li>";
|
1005 |
return false;
|
1006 |
}
|
1007 |
return true;
|
1137 |
$age = intval(($now - $sizes['ts'])/60);
|
1138 |
echo "<li>" . intval($sizes['expired']/2) . " Expired Pages</li></ul>";
|
1139 |
}
|
1140 |
+
$last_gc = get_option( "wpsupercache_gc_time" );
|
1141 |
+
if( $last_gc ) {
|
1142 |
+
$next_gc = $cache_max_time < 1800 ? $cache_max_time : 600;
|
1143 |
+
echo "<p><strong>Garbage Collection</strong><br />Last: " . date( "Y-m-d H:i:s", $last_gc ) . "<br />";
|
1144 |
+
echo "Next: " . date( "Y-m-d H:i:s", $next_gc + $last_gc ) . "</p>";
|
1145 |
+
}
|
1146 |
|
1147 |
+
echo "<p>Expired files are files older than $cache_max_time seconds. They are still used by the plugin and are deleted periodically.</p>";
|
1148 |
echo '<form name="wp_cache_content_expired" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
|
1149 |
echo '<input type="hidden" name="wp_delete_expired" />';
|
1150 |
echo '<div class="submit" style="float:left"><input type="submit" ' . SUBMITDISABLED . 'value="Delete Expired »" /></div>';
|