WP Super Cache - Version 0.8.3

Version Description

Download this release

Release Info

Developer donncha
Plugin Icon 128x128 WP Super Cache
Version 0.8.3
Comparing to
See all releases

Code changes from version 0.8.2 to 0.8.3

Changelog.txt CHANGED
@@ -1,3 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  2008-09-26 23:15 donncha
2
 
3
  * readme.txt, wp-cache.php: Bump the version number to 0.8.2
1
+ 2008-10-08 16:04 donncha
2
+
3
+ * readme.txt, wp-cache.php: Bump version numbers to 0.8.3
4
+ Updated docs
5
+
6
+ 2008-10-08 08:12 donncha
7
+
8
+ * readme.txt: Note for WPMU users,
9
+ http://wordpress.org/support/topic/208770?replies=3#post-871207
10
+
11
+ 2008-10-07 12:03 donncha
12
+
13
+ * readme.txt: x-gzip->gzip
14
+
15
+ 2008-10-07 10:50 donncha
16
+
17
+ * readme.txt: Minor typo,
18
+ http://wordpress.org/support/topic/208770?replies=1#post-870518
19
+
20
+ 2008-10-07 10:44 donncha
21
+
22
+ * plugins/searchengine.php: Don't overwrite logged in user details
23
+ in searchengine plugin.
24
+
25
+ 2008-10-06 09:19 donncha
26
+
27
+ * wp-cache-phase1.php, wp-cache.php: Encode as gzip, not x-gzip as
28
+ IE7 has problems with it. ref:
29
+ http://bugs.typo3.org/view.php?id=4623
30
+
31
+ 2008-10-01 08:05 donncha
32
+
33
+ * readme.txt, wp-cache.php: Options -> Settings, thanks webmaestro
34
+ http://wordpress.org/support/topic/207576?replies=2
35
+
36
+ 2008-09-29 09:29 donncha
37
+
38
+ * wp-cache.php: Only update "clear on post" setting when saving
39
+ status options, thanks Viper007Bond
40
+
41
+ 2008-09-28 11:04 donncha
42
+
43
+ * wp-cache-phase2.php: Only create compressed data if required
44
+
45
+ 2008-09-28 06:16 donncha
46
+
47
+ * wp-cache-phase2.php: Compress cache files with "dynamic content"
48
+ too
49
+
50
+ 2008-09-28 05:56 donncha
51
+
52
+ * wp-cache-phase2.php: Only compress cached files once. Nice speed
53
+ boost!
54
+
55
+ 2008-09-28 05:46 donncha
56
+
57
+ * wp-cache-phase2.php: Write gzipped supercache files using fopen
58
+ instead of gzopen
59
+
60
+ 2008-09-26 23:16 donncha
61
+
62
+ * Changelog.txt: Updated changelog
63
+
64
  2008-09-26 23:15 donncha
65
 
66
  * readme.txt, wp-cache.php: Bump the version number to 0.8.2
plugins/searchengine.php CHANGED
@@ -5,6 +5,9 @@ function wp_supercache_searchengine( $string ) {
5
  if( $cache_no_adverts_for_friends != 'yes' )
6
  return $string;
7
 
 
 
 
8
  if( $_COOKIE[ '7a1254cba80da02d5478d91cfd0a873a' ] == 1 ) {
9
  $string = 'searchengine';
10
  } elseif( $_SERVER[ 'HTTP_REFERER' ] != '' ) {
5
  if( $cache_no_adverts_for_friends != 'yes' )
6
  return $string;
7
 
8
+ if( $string != '' )
9
+ return $string;
10
+
11
  if( $_COOKIE[ '7a1254cba80da02d5478d91cfd0a873a' ] == 1 ) {
12
  $string = 'searchengine';
13
  } elseif( $_SERVER[ 'HTTP_REFERER' ] != '' ) {
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: donncha
3
  Tags: performance,caching,wp-cache
4
  Tested up to: 2.6.2
5
- Stable tag: 0.8.2
6
  Requires at least: 2.2
7
 
8
  A very fast caching engine for WordPress that produces static html files.
@@ -31,7 +31,7 @@ The [changelog](http://svn.wp-plugins.org/wp-super-cache/trunk/Changelog.txt) is
31
  3. Upload this directory to your plugins directory. It will create a 'wp-content/plugins/wp-super-cache/' directory.
32
  4. If you are using WordPress MU you will need to install this in 'wp-content/mu-plugins/wp-super-cache/' and the file wp-cache.php must be copied into the mu-plugins directory.
33
  5. WordPress users should go to their Plugins page and activate "WP Super Cache".
34
- 6. Now go to Options->WP Super Cache and enable caching. If you see an error message or a blank screen you may need to fix it. See the "FAQ" section later in this readme for instructions.
35
  7. mod_rewrite rules will be inserted into your .htaccess file. Look in your web root directory for this file. It should look similar to this:
36
 
37
  `-----------------.htaccess-----------------`
@@ -60,7 +60,7 @@ The [changelog](http://svn.wp-plugins.org/wp-super-cache/trunk/Changelog.txt) is
60
 
61
  `# BEGIN supercache`
62
  `<IfModule mod_mime.c>`
63
- ` AddEncoding x-gzip .gz`
64
  ` AddType text/html .gz`
65
  `</IfModule>`
66
  `<IfModule mod_deflate.c>`
@@ -78,6 +78,10 @@ The [changelog](http://svn.wp-plugins.org/wp-super-cache/trunk/Changelog.txt) is
78
 
79
  == Frequently Asked Questions ==
80
 
 
 
 
 
81
  = Why is WP-Super-Cache better than WP-Cache? =
82
 
83
  This plugin is based on the excellent WP-Cache plugin and therefore brings all the benefits of that plugin to WordPress. On top of that it creates copies of every page that is accessed on a blog in a form that is quickly served by the web server. It's almost as quick as if the you had saved a page in your browser and uploaded it to replace your homepage.
@@ -86,10 +90,6 @@ This plugin is based on the excellent WP-Cache plugin and therefore brings all t
86
 
87
  Comments will show as soon as they are moderated, depending on the comment policy of the blog owner. Other dynamic elements on a page may not update unless they are written in Javascript, Flash, Java or another client side browser language. The plugin really produces static html pages. No PHP is executed when those pages are served. "Popularity Contest" is one such plugin that will not work.
88
 
89
- = Why are there two expiry times? =
90
-
91
- WP Super Cache stores it's cached files in a different way to WP Cache that lets it work better even when there are very many cached files. That is why the Super Cache expiry time is so much longer by default. If your site starts to slow down and there are too many cached files reduce these times and change the garbage collection number too.
92
-
93
  = Will the Super Cache compression slow down my server? =
94
 
95
  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.
@@ -109,7 +109,7 @@ If things don't work when you installed the plugin here are a few things to chec
109
 
110
  1. Is wp-content writable by the web server?
111
  2. Is there a wp-content/wp-cache-config.php ? If not, copy the file wp-super-cache/wp-cache-config-sample.php to wp-content/wp-cache-config.php and make sure WPCACHEHOME points at the right place. "plugins" should be "mu-plugins" if you're using WordPress MU.
112
- 3. Is there a wp-content/advanced-cache.php ? If not, then you must symlink wp-super-cache/wp-cache-phase1.php to it with this command while in the wp-content folder.
113
 
114
  `ln -s plugins/wp-super-cache/wp-cache-phase1.php advanced-cache.php`
115
  If you can't do that, then copy the file. That will work too.
@@ -117,17 +117,17 @@ If you can't do that, then copy the file. That will work too.
117
  5. Make sure the following line is in wp-config.php and it is ABOVE the "require_once(ABSPATH.'wp-settings.php');" line:
118
 
119
  `define( 'WP_CACHE', true );`
120
- 6. Try the Options->WP Super Cache page again and enable cache.
121
  7. Look in wp-content/cache/supercache/. Are there directories and files there?
122
  8. Anything in your php error_log?
123
- 9. If your browser keeps asking you to save the file after the super cache is installed you must disable Super Cache compression. Go to the Options->WP Super Cache page and disable it there.
124
- 10. The plugin does not work very well when PHP's safe mode is active. This must be disabled by your administrator.
125
  11. If pages are randomly super cached and sometimes not, your blog can probably be viewed with and without the "www" prefix on the URL. You should choose one way and install the [Enforce www preference](http://txfx.net/code/wordpress/enforce-www-preference/) plugin.
126
  12. Private Server users at Dreamhost should edit wp-content/wp-cache-config.php and set the cache dir to "/tmp/" if they are getting errors about increasing CPU usage. See this [discussion](http://wordpress.org/support/topic/145895?replies=42) for more.
127
  13. sem_acquire() errors such as "failed to acquire key 0x152b: Permission denied in..." are a sign that you must use file locking. Edit wp-content/wp-cache-config.php and uncomment "$use_flock = true" or set $sem_id to a different value.
128
 
129
  == Custom Caching ==
130
- It is now possible to hook into the caching process using the add_cacheacton() function.
131
 
132
  Three hooks are available:
133
 
2
  Contributors: donncha
3
  Tags: performance,caching,wp-cache
4
  Tested up to: 2.6.2
5
+ Stable tag: 0.8.3
6
  Requires at least: 2.2
7
 
8
  A very fast caching engine for WordPress that produces static html files.
31
  3. Upload this directory to your plugins directory. It will create a 'wp-content/plugins/wp-super-cache/' directory.
32
  4. If you are using WordPress MU you will need to install this in 'wp-content/mu-plugins/wp-super-cache/' and the file wp-cache.php must be copied into the mu-plugins directory.
33
  5. WordPress users should go to their Plugins page and activate "WP Super Cache".
34
+ 6. Now go to Settings->WP Super Cache and enable caching. If you see an error message or a blank screen you may need to fix it. See the "FAQ" section later in this readme for instructions.
35
  7. mod_rewrite rules will be inserted into your .htaccess file. Look in your web root directory for this file. It should look similar to this:
36
 
37
  `-----------------.htaccess-----------------`
60
 
61
  `# BEGIN supercache`
62
  `<IfModule mod_mime.c>`
63
+ ` AddEncoding gzip .gz`
64
  ` AddType text/html .gz`
65
  `</IfModule>`
66
  `<IfModule mod_deflate.c>`
78
 
79
  == Frequently Asked Questions ==
80
 
81
+ = How do I know my blog is being cached? =
82
+
83
+ View the source of any page on your site. When a page is first created, you'll see the text "Dynamic Page Served (once) in X.XXXXX seconds" at the end of the source code. On reload, a cached page displays, "Cached page served by WP-Super-Cache". Check your cache directory wp-content/cache/supercache/hostname/ for static cache files.
84
+
85
  = Why is WP-Super-Cache better than WP-Cache? =
86
 
87
  This plugin is based on the excellent WP-Cache plugin and therefore brings all the benefits of that plugin to WordPress. On top of that it creates copies of every page that is accessed on a blog in a form that is quickly served by the web server. It's almost as quick as if the you had saved a page in your browser and uploaded it to replace your homepage.
90
 
91
  Comments will show as soon as they are moderated, depending on the comment policy of the blog owner. Other dynamic elements on a page may not update unless they are written in Javascript, Flash, Java or another client side browser language. The plugin really produces static html pages. No PHP is executed when those pages are served. "Popularity Contest" is one such plugin that will not work.
92
 
 
 
 
 
93
  = Will the Super Cache compression slow down my server? =
94
 
95
  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.
109
 
110
  1. Is wp-content writable by the web server?
111
  2. Is there a wp-content/wp-cache-config.php ? If not, copy the file wp-super-cache/wp-cache-config-sample.php to wp-content/wp-cache-config.php and make sure WPCACHEHOME points at the right place. "plugins" should be "mu-plugins" if you're using WordPress MU.
112
+ 3. Is there a wp-content/advanced-cache.php ? If not, then you must symlink wp-super-cache/wp-cache-phase1.php to it with this command while in the wp-content folder. (WordPress MU users should replace "plugins" with "mu-plugins".)
113
 
114
  `ln -s plugins/wp-super-cache/wp-cache-phase1.php advanced-cache.php`
115
  If you can't do that, then copy the file. That will work too.
117
  5. Make sure the following line is in wp-config.php and it is ABOVE the "require_once(ABSPATH.'wp-settings.php');" line:
118
 
119
  `define( 'WP_CACHE', true );`
120
+ 6. Try the Settings->WP Super Cache page again and enable cache.
121
  7. Look in wp-content/cache/supercache/. Are there directories and files there?
122
  8. Anything in your php error_log?
123
+ 9. If your browser keeps asking you to save the file after the super cache is installed you must disable Super Cache compression. Go to the Settings->WP Super Cache page and disable it there.
124
+ 10. The plugin does not work very well when PHP's safe mode is active. This must be disabled by your administrator.
125
  11. If pages are randomly super cached and sometimes not, your blog can probably be viewed with and without the "www" prefix on the URL. You should choose one way and install the [Enforce www preference](http://txfx.net/code/wordpress/enforce-www-preference/) plugin.
126
  12. Private Server users at Dreamhost should edit wp-content/wp-cache-config.php and set the cache dir to "/tmp/" if they are getting errors about increasing CPU usage. See this [discussion](http://wordpress.org/support/topic/145895?replies=42) for more.
127
  13. sem_acquire() errors such as "failed to acquire key 0x152b: Permission denied in..." are a sign that you must use file locking. Edit wp-content/wp-cache-config.php and uncomment "$use_flock = true" or set $sem_id to a different value.
128
 
129
  == Custom Caching ==
130
+ It is now possible to hook into the caching process using the add_cacheaction() function.
131
 
132
  Three hooks are available:
133
 
wp-cache-phase1.php CHANGED
@@ -42,8 +42,7 @@ function gzip_accepted(){
42
  return false;
43
 
44
  if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === false) return false;
45
- if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip') === false) return 'gzip';
46
- return 'x-gzip';
47
  }
48
 
49
  if ($cache_compression) {
42
  return false;
43
 
44
  if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === false) return false;
45
+ return 'gzip';
 
46
  }
47
 
48
  if ($cache_compression) {
wp-cache-phase2.php CHANGED
@@ -219,7 +219,7 @@ function wp_cache_ob_callback($buffer) {
219
  $tmp_cache_filename = tempnam( $dir, "wpsupercache");
220
  $fr2 = @fopen( $tmp_cache_filename, 'w' );
221
  if( $cache_compression )
222
- $gz = @gzopen( $tmp_cache_filename . ".gz", 'w3');
223
  }
224
  }
225
 
@@ -236,15 +236,15 @@ function wp_cache_ob_callback($buffer) {
236
  if( $fr2 )
237
  fputs($fr2, $store . '<!-- super cache -->' );
238
  if( $gz )
239
- gzwrite($gz, $store . '<!-- super cache gz -->' );
240
  } else {
241
- $log = "<!-- Cached page served by WP-Cache -->\n";
242
 
243
- if ($wp_cache_gzip_encoding) {
244
- $log .= "<!-- Compression = " . $wp_cache_gzip_encoding ." -->";
245
- $gzdata = gzencode($buffer . $log, 3, FORCE_GZIP);
246
  $gzsize = strlen($gzdata);
247
-
 
248
  array_push($wp_cache_meta_object->headers, 'Content-Encoding: ' . $wp_cache_gzip_encoding);
249
  array_push($wp_cache_meta_object->headers, 'Vary: Accept-Encoding, Cookie');
250
  array_push($wp_cache_meta_object->headers, 'Content-Length: ' . strlen($gzdata));
@@ -257,7 +257,7 @@ function wp_cache_ob_callback($buffer) {
257
  if( $fr2 )
258
  fputs($fr2, $buffer . '<!-- super cache -->' );
259
  if( $gz )
260
- gzwrite($gz, $buffer . '<!-- super cache gz -->' );
261
  }
262
  $new_cache = true;
263
  fclose($fr);
219
  $tmp_cache_filename = tempnam( $dir, "wpsupercache");
220
  $fr2 = @fopen( $tmp_cache_filename, 'w' );
221
  if( $cache_compression )
222
+ $gz = @fopen( $tmp_cache_filename . ".gz", 'w');
223
  }
224
  }
225
 
236
  if( $fr2 )
237
  fputs($fr2, $store . '<!-- super cache -->' );
238
  if( $gz )
239
+ fputs($gz, gzencode( $store . '<!-- super cache gz -->', 1, FORCE_GZIP ) );
240
  } else {
241
+ $log = "<!-- Cached page served by WP-Super-Cache -->\n";
242
 
243
+ if( $gz || $wp_cache_gzip_encoding ) {
244
+ $gzdata = gzencode( $buffer . $log . "<!-- Compression = gzip -->", 1, FORCE_GZIP );
 
245
  $gzsize = strlen($gzdata);
246
+ }
247
+ if ($wp_cache_gzip_encoding) {
248
  array_push($wp_cache_meta_object->headers, 'Content-Encoding: ' . $wp_cache_gzip_encoding);
249
  array_push($wp_cache_meta_object->headers, 'Vary: Accept-Encoding, Cookie');
250
  array_push($wp_cache_meta_object->headers, 'Content-Length: ' . strlen($gzdata));
257
  if( $fr2 )
258
  fputs($fr2, $buffer . '<!-- super cache -->' );
259
  if( $gz )
260
+ fwrite($gz, $gzdata );
261
  }
262
  $new_cache = true;
263
  fclose($fr);
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. Once activated, you must <a href="options-general.php?page=wpsupercache">enable the cache</a>. Based on WP-Cache by <a href="http://mnm.uib.es/gallir/">Ricardo Galli Granada</a>.
6
- Version: 0.8.2
7
  Author: Donncha O Caoimh
8
  Author URI: http://ocaoimh.ie/
9
  */
@@ -160,7 +160,7 @@ function toggleLayer( whichLayer ) {
160
  }
161
  if(isset($_REQUEST['wp_restore_config']) && $valid_nonce) {
162
  unlink($wp_cache_config_file);
163
- echo '<strong>Configuration file changed, some values might be wrong. Load the page again from the "Options" menu to reset them.</strong>';
164
  }
165
 
166
  if ( !wp_cache_check_link() ||
@@ -220,11 +220,17 @@ function toggleLayer( whichLayer ) {
220
  break;
221
  }
222
  if( isset( $_POST[ 'wp_cache_hello_world' ] ) ) {
223
- $wp_cache_hello_world = (int)$_POST[ 'wp_cache_hello_world' ];
224
  } else {
225
  $wp_cache_hello_world = 0;
226
  }
227
  wp_cache_replace_line('^ *\$wp_cache_hello_world', '$wp_cache_hello_world = ' . (int)$wp_cache_hello_world . ";", $wp_cache_config_file);
 
 
 
 
 
 
228
  }
229
  if( isset( $_POST[ 'cache_compression' ] ) && $_POST[ 'cache_compression' ] != $cache_compression ) {
230
  $cache_compression_changed = true;
@@ -234,12 +240,6 @@ function toggleLayer( whichLayer ) {
234
  prune_super_cache ($cache_path, true);
235
  delete_option( 'super_cache_meta' );
236
  }
237
- if( isset( $_POST[ 'wp_cache_clear_on_post_edit' ] ) ) {
238
- $wp_cache_clear_on_post_edit = 1;
239
- } else {
240
- $wp_cache_clear_on_post_edit = 0;
241
- }
242
- wp_cache_replace_line('^ *\$wp_cache_clear_on_post_edit', "\$wp_cache_clear_on_post_edit = " . $wp_cache_clear_on_post_edit . ";", $wp_cache_config_file);
243
  }
244
 
245
  ?><fieldset class="options">
@@ -413,7 +413,7 @@ function wsc_mod_rewrite() {
413
  }
414
  // http://allmybrain.com/2007/11/08/making-wp-super-cache-gzip-compression-work/
415
  if( !is_file( $cache_path . '.htaccess' ) ) {
416
- $gziprules = "<IfModule mod_mime.c>\n AddEncoding x-gzip .gz\n AddType text/html .gz\n</IfModule>\n";
417
  $gziprules .= "<IfModule mod_deflate.c>\n SetEnvIfNoCase Request_URI \.gz$ no-gzip\n</IfModule>\n";
418
  $gziprules .= "<IfModule mod_headers.c>\n Header set Cache-Control 'max-age=300, must-revalidate'\n</IfModule>\n";
419
  $gziprules .= "<IfModule mod_expires.c>\n ExpiresActive On\n ExpiresByType text/html A300\n</IfModule>\n";
3
  Plugin Name: WP Super Cache
4
  Plugin URI: http://ocaoimh.ie/wp-super-cache/
5
  Description: Very fast caching module for WordPress. Once activated, you must <a href="options-general.php?page=wpsupercache">enable the cache</a>. Based on WP-Cache by <a href="http://mnm.uib.es/gallir/">Ricardo Galli Granada</a>.
6
+ Version: 0.8.3
7
  Author: Donncha O Caoimh
8
  Author URI: http://ocaoimh.ie/
9
  */
160
  }
161
  if(isset($_REQUEST['wp_restore_config']) && $valid_nonce) {
162
  unlink($wp_cache_config_file);
163
+ echo '<strong>Configuration file changed, some values might be wrong. Load the page again from the "Settings" menu to reset them.</strong>';
164
  }
165
 
166
  if ( !wp_cache_check_link() ||
220
  break;
221
  }
222
  if( isset( $_POST[ 'wp_cache_hello_world' ] ) ) {
223
+ $wp_cache_hello_world = 1;
224
  } else {
225
  $wp_cache_hello_world = 0;
226
  }
227
  wp_cache_replace_line('^ *\$wp_cache_hello_world', '$wp_cache_hello_world = ' . (int)$wp_cache_hello_world . ";", $wp_cache_config_file);
228
+ if( isset( $_POST[ 'wp_cache_clear_on_post_edit' ] ) ) {
229
+ $wp_cache_clear_on_post_edit = 1;
230
+ } else {
231
+ $wp_cache_clear_on_post_edit = 0;
232
+ }
233
+ wp_cache_replace_line('^ *\$wp_cache_clear_on_post_edit', "\$wp_cache_clear_on_post_edit = " . $wp_cache_clear_on_post_edit . ";", $wp_cache_config_file);
234
  }
235
  if( isset( $_POST[ 'cache_compression' ] ) && $_POST[ 'cache_compression' ] != $cache_compression ) {
236
  $cache_compression_changed = true;
240
  prune_super_cache ($cache_path, true);
241
  delete_option( 'super_cache_meta' );
242
  }
 
 
 
 
 
 
243
  }
244
 
245
  ?><fieldset class="options">
413
  }
414
  // http://allmybrain.com/2007/11/08/making-wp-super-cache-gzip-compression-work/
415
  if( !is_file( $cache_path . '.htaccess' ) ) {
416
+ $gziprules = "<IfModule mod_mime.c>\n AddEncoding gzip .gz\n AddType text/html .gz\n</IfModule>\n";
417
  $gziprules .= "<IfModule mod_deflate.c>\n SetEnvIfNoCase Request_URI \.gz$ no-gzip\n</IfModule>\n";
418
  $gziprules .= "<IfModule mod_headers.c>\n Header set Cache-Control 'max-age=300, must-revalidate'\n</IfModule>\n";
419
  $gziprules .= "<IfModule mod_expires.c>\n ExpiresActive On\n ExpiresByType text/html A300\n</IfModule>\n";