WP Super Cache - Version 0.6.5

Version Description

Download this release

Release Info

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

Code changes from version 0.6.4 to 0.6.5

Files changed (5) hide show
  1. Changelog.txt +69 -0
  2. readme.txt +18 -14
  3. wp-cache-phase1.php +1 -1
  4. wp-cache-phase2.php +24 -19
  5. wp-cache.php +28 -7
Changelog.txt CHANGED
@@ -1,3 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  2008-05-14 12:21 donncha
2
 
3
  * wp-cache-phase2.php: Clean up the supercache if no post_id is
1
+ 2008-07-15 10:15 donncha
2
+
3
+ * readme.txt, wp-cache.php: Bump the version number to 0.6.5
4
+
5
+ 2008-07-15 10:14 donncha
6
+
7
+ * readme.txt: Add "Subscribe to comments" rule to readme
8
+
9
+ 2008-07-15 10:11 donncha
10
+
11
+ * wp-cache-phase1.php: Use comment_author instead of email in case
12
+ email isn't mandatory. props rhapsodyv @
13
+ http://wordpress.org/support/topic/188775
14
+
15
+ 2008-07-14 10:42 donncha
16
+
17
+ * wp-cache-phase2.php, wp-cache.php: Added "wp_cache_gc" option
18
+ Allow chance of garbage collection to be configurable.
19
+
20
+ 2008-07-14 10:06 donncha
21
+
22
+ * readme.txt: If caching doesn't work, it could be
23
+ advanced-cache.php
24
+
25
+ 2008-07-14 09:53 donncha
26
+
27
+ * wp-cache.php: Added Subscribe To Comments exclusion rewrite rule
28
+
29
+ 2008-07-14 09:52 donncha
30
+
31
+ * wp-cache.php: Warn if wp-content is writable, props alexleonard,
32
+ http://wordpress.org/support/topic/188530
33
+
34
+ 2008-07-08 10:41 donncha
35
+
36
+ * wp-cache-phase2.php: Remove extra pages generated at the current
37
+ permalink. ie. paged comments.
38
+
39
+ 2008-06-20 16:16 donncha
40
+
41
+ * wp-cache.php: Only need the config file writable to change it
42
+
43
+ 2008-06-16 09:08 donncha
44
+
45
+ * wp-cache-phase2.php: Increase the chance of expired file cleanup
46
+
47
+ 2008-06-16 09:07 donncha
48
+
49
+ * wp-cache-phase2.php: Warn if page is a 404 or not complete and
50
+ won't be cached
51
+
52
+ 2008-06-12 09:53 donncha
53
+
54
+ * readme.txt: Add troubleshooting message for Dreamhost users
55
+
56
+ 2008-05-26 09:12 donncha
57
+
58
+ * wp-cache-phase2.php: Use [] instead of {} for array indexes
59
+ Fix warning notices
60
+
61
+ 2008-05-14 16:22 donncha
62
+
63
+ * Changelog.txt: Updated changelog
64
+
65
+ 2008-05-14 16:19 donncha
66
+
67
+ * readme.txt, wp-cache-phase2.php, wp-cache.php: Remove comment.
68
+ Bump version number
69
+
70
  2008-05-14 12:21 donncha
71
 
72
  * wp-cache-phase2.php: Clean up the supercache if no post_id is
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === WP Super Cache ===
2
  Contributors: donncha
3
  Tags: performance,caching,wp-cache
4
- Tested up to: 2.5.1
5
- Stable tag: 0.6.4
6
  Requires at least: 2.2
7
 
8
  A very fast caching engine for WordPress that produces static html files.
@@ -41,6 +41,7 @@ The [changelog](http://svn.wp-plugins.org/wp-super-cache/trunk/Changelog.txt) is
41
  `RewriteCond %{REQUEST_METHOD} !=POST`
42
  `RewriteCond %{QUERY_STRING} !.*s=.*`
43
  `RewriteCond %{QUERY_STRING} !.*attachment_id=.*`
 
44
  `RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$`
45
  `RewriteCond %{HTTP:Accept-Encoding} gzip`
46
  `RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f`
@@ -48,6 +49,7 @@ The [changelog](http://svn.wp-plugins.org/wp-super-cache/trunk/Changelog.txt) is
48
 
49
  `RewriteCond %{REQUEST_METHOD} !=POST`
50
  `RewriteCond %{QUERY_STRING} !.*s=.*`
 
51
  `RewriteCond %{QUERY_STRING} !.*attachment_id=.*`
52
  `RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$`
53
  `RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f`
@@ -83,11 +85,11 @@ No, it will do the opposite in fact. Super Cache files are compressed and stored
83
  = How do I uninstall WP Super Cache? =
84
 
85
  1. Clear the cache in the backend page and then deactivate it on the plugins page.
86
- 1. Remove the Super Cache mod_rewrite rules from your .htaccess file.
87
- 1. Remove the WP_CACHE define from wp-config.php
88
- 1. Remove the files wp-content/advanced-cache.php and wp-content/wp-cache-config.php
89
- 1. Remove the directory wp-content/cache/
90
- 1. Remove the directory wp-super-cache from your plugins directory.
91
 
92
  = Troubleshooting =
93
 
@@ -99,15 +101,17 @@ If things don't work when you installed the plugin here are a few things to chec
99
 
100
  `ln -s plugins/wp-super-cache/wp-cache-phase1.php advanced-cache.php`
101
  If you can't do that, then copy the file. That will work too.
102
- 4. Make sure the following line is in wp-config.php and it is ABOVE the "require_once(ABSPATH.'wp-settings.php');" line:
 
103
 
104
  `define( 'WP_CACHE', true );`
105
- 5. Try the Options->WP Super Cache page again and enable cache.
106
- 6. Look in wp-content/cache/supercache/. Are there directories and files there?
107
- 7. Anything in your php error_log?
108
- 8. 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.
109
- 9. The plugin does not work very well when PHP's safe mode is active. This must be disabled by your administrator.
110
- 10. 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.
 
111
 
112
  == Custom Caching ==
113
  It is now possible to hook into the caching process using the add_cacheacton() function.
1
  === WP Super Cache ===
2
  Contributors: donncha
3
  Tags: performance,caching,wp-cache
4
+ Tested up to: 2.6
5
+ Stable tag: 0.6.5
6
  Requires at least: 2.2
7
 
8
  A very fast caching engine for WordPress that produces static html files.
41
  `RewriteCond %{REQUEST_METHOD} !=POST`
42
  `RewriteCond %{QUERY_STRING} !.*s=.*`
43
  `RewriteCond %{QUERY_STRING} !.*attachment_id=.*`
44
+ `RewriteCond %{QUERY_STRING} !.*wp-subscription-manager=.*`
45
  `RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$`
46
  `RewriteCond %{HTTP:Accept-Encoding} gzip`
47
  `RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f`
49
 
50
  `RewriteCond %{REQUEST_METHOD} !=POST`
51
  `RewriteCond %{QUERY_STRING} !.*s=.*`
52
+ `RewriteCond %{QUERY_STRING} !.*wp-subscription-manager=.*`
53
  `RewriteCond %{QUERY_STRING} !.*attachment_id=.*`
54
  `RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$`
55
  `RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f`
85
  = How do I uninstall WP Super Cache? =
86
 
87
  1. Clear the cache in the backend page and then deactivate it on the plugins page.
88
+ 2. Remove the Super Cache mod_rewrite rules from your .htaccess file.
89
+ 3. Remove the WP_CACHE define from wp-config.php
90
+ 4. Remove the files wp-content/advanced-cache.php and wp-content/wp-cache-config.php
91
+ 5. Remove the directory wp-content/cache/
92
+ 6. Remove the directory wp-super-cache from your plugins directory.
93
 
94
  = Troubleshooting =
95
 
101
 
102
  `ln -s plugins/wp-super-cache/wp-cache-phase1.php advanced-cache.php`
103
  If you can't do that, then copy the file. That will work too.
104
+ 4. If pages are not cached at all, remove wp-content/advanced-cache.php and recreate it, following the advice above.
105
+ 5. Make sure the following line is in wp-config.php and it is ABOVE the "require_once(ABSPATH.'wp-settings.php');" line:
106
 
107
  `define( 'WP_CACHE', true );`
108
+ 6. Try the Options->WP Super Cache page again and enable cache.
109
+ 7. Look in wp-content/cache/supercache/. Are there directories and files there?
110
+ 8. Anything in your php error_log?
111
+ 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.
112
+ 10. The plugin does not work very well when PHP's safe mode is active. This must be disabled by your administrator.
113
+ 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.
114
+ 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.
115
 
116
  == Custom Caching ==
117
  It is now possible to hook into the caching process using the add_cacheacton() function.
wp-cache-phase1.php CHANGED
@@ -89,7 +89,7 @@ function wp_cache_postload() {
89
  function wp_cache_get_cookies_values() {
90
  $string = '';
91
  while ($key = key($_COOKIE)) {
92
- if (preg_match("/^wp-postpass|^wordpress|^comment_author_email_/", $key)) {
93
  $string .= $_COOKIE[$key] . ",";
94
  }
95
  next($_COOKIE);
89
  function wp_cache_get_cookies_values() {
90
  $string = '';
91
  while ($key = key($_COOKIE)) {
92
+ if (preg_match("/^wp-postpass|^wordpress|^comment_author_/", $key)) {
93
  $string .= $_COOKIE[$key] . ",";
94
  }
95
  next($_COOKIE);
wp-cache-phase2.php CHANGED
@@ -1,12 +1,5 @@
1
  <?php
2
 
3
- /** Diable here because PHP4.3 does not make the global
4
- Serious bug?
5
-
6
- $mutex_filename = 'wp_cache_mutex.lock';
7
- $new_cache = false;
8
- */
9
-
10
  function wp_cache_phase2() {
11
  global $cache_filename, $cache_acceptable_files, $wp_cache_meta_object;
12
  global $wp_cache_gzip_encoding;
@@ -132,13 +125,23 @@ function wp_cache_ob_callback($buffer) {
132
  global $new_cache, $wp_cache_meta_object, $file_expired, $blog_id, $cache_compression;
133
  global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
134
 
 
 
135
  /* Mode paranoic, check for closing tags
136
  * we avoid caching incomplete files */
137
- if (is_404() || !preg_match('/(<\/html>|<\/rss>|<\/feed>)/i',$buffer) ) {
138
  $new_cache = false;
139
- return $buffer;
140
  }
141
 
 
 
 
 
 
 
 
 
142
  $duration = wp_cache_microtime_diff($wp_start_time, microtime());
143
  $duration = sprintf("%0.3f", $duration);
144
  $buffer .= "\n<!-- Dynamic Page Served (once) in $duration seconds -->\n";
@@ -310,8 +313,7 @@ function wp_cache_phase2_clean_expired($file_prefix) {
310
  }
311
 
312
  function wp_cache_shutdown_callback() {
313
- global $cache_path, $cache_max_time, $file_expired, $file_prefix, $meta_file, $new_cache;
314
- global $wp_cache_meta_object, $known_headers, $blog_id;
315
 
316
  $wp_cache_meta_object->uri = $_SERVER["SERVER_NAME"].preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI']); // To avoid XSS attacs
317
  $wp_cache_meta_object->blog_id=$blog_id;
@@ -319,8 +321,8 @@ function wp_cache_shutdown_callback() {
319
 
320
  $response = wp_cache_get_response_headers();
321
  foreach ($known_headers as $key) {
322
- if(isset($response{$key})) {
323
- array_push($wp_cache_meta_object->headers, "$key: " . $response{$key});
324
  }
325
  }
326
  /* Not used because it gives problems with some
@@ -332,13 +334,13 @@ function wp_cache_shutdown_callback() {
332
  array_push($wp_cache_meta_object->headers, "Content-Length: $content_size");
333
  }
334
  */
335
- if (!$response{'Last-Modified'}) {
336
  $value = gmdate('D, d M Y H:i:s') . ' GMT';
337
  /* Dont send this the first time */
338
  /* @header('Last-Modified: ' . $value); */
339
  array_push($wp_cache_meta_object->headers, "Last-Modified: $value");
340
  }
341
- if (!$response{'Content-Type'} && !$response{'Content-type'}) {
342
  // On some systems, headers set by PHP can't be fetched from
343
  // the output buffer. This is a last ditch effort to set the
344
  // correct Content-Type header for feeds, if we didn't see
@@ -367,7 +369,7 @@ function wp_cache_shutdown_callback() {
367
  array_push($wp_cache_meta_object->headers, "Content-Type: $value");
368
  }
369
 
370
- ob_end_flush();
371
  if ($new_cache) {
372
  $serial = serialize($wp_cache_meta_object);
373
  if( !wp_cache_writers_entry() )
@@ -381,7 +383,9 @@ function wp_cache_shutdown_callback() {
381
  wp_cache_writers_exit();
382
  }
383
 
384
- if( mt_rand( 0, 500 ) != 1 )
 
 
385
  return;
386
 
387
  // we delete expired files
@@ -433,6 +437,7 @@ function wp_cache_post_change($post_id) {
433
  @unlink( $cache_file );
434
  @unlink( $cache_file . '.gz' );
435
  }
 
436
  }
437
  }
438
 
@@ -476,8 +481,8 @@ function wp_cache_post_id() {
476
  if ($post_ID > 0 ) return $post_ID;
477
  if ($comment_post_ID > 0 ) return $comment_post_ID;
478
  if (is_single() || is_page()) return $posts[0]->ID;
479
- if ($_GET['p'] > 0) return $_GET['p'];
480
- if ($_POST['p'] > 0) return $_POST['p'];
481
  return 0;
482
  }
483
  ?>
1
  <?php
2
 
 
 
 
 
 
 
 
3
  function wp_cache_phase2() {
4
  global $cache_filename, $cache_acceptable_files, $wp_cache_meta_object;
5
  global $wp_cache_gzip_encoding;
125
  global $new_cache, $wp_cache_meta_object, $file_expired, $blog_id, $cache_compression;
126
  global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
127
 
128
+ $new_cache = true;
129
+
130
  /* Mode paranoic, check for closing tags
131
  * we avoid caching incomplete files */
132
+ if (is_404()) {
133
  $new_cache = false;
134
+ $buffer .= "\n<!-- Page not cached by WP Super Cache. 404. -->\n";
135
  }
136
 
137
+ if (!preg_match('/(<\/html>|<\/rss>|<\/feed>)/i',$buffer) ) {
138
+ $new_cache = false;
139
+ $buffer .= "\n<!-- Page not cached by WP Super Cache. No closing HTML tag. Check your theme. -->\n";
140
+ }
141
+
142
+ if( !$new_cache )
143
+ return $buffer;
144
+
145
  $duration = wp_cache_microtime_diff($wp_start_time, microtime());
146
  $duration = sprintf("%0.3f", $duration);
147
  $buffer .= "\n<!-- Dynamic Page Served (once) in $duration seconds -->\n";
313
  }
314
 
315
  function wp_cache_shutdown_callback() {
316
+ global $cache_path, $cache_max_time, $file_expired, $file_prefix, $meta_file, $new_cache, $wp_cache_meta_object, $known_headers, $blog_id, $wp_cache_gc;
 
317
 
318
  $wp_cache_meta_object->uri = $_SERVER["SERVER_NAME"].preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI']); // To avoid XSS attacs
319
  $wp_cache_meta_object->blog_id=$blog_id;
321
 
322
  $response = wp_cache_get_response_headers();
323
  foreach ($known_headers as $key) {
324
+ if(isset($response[$key])) {
325
+ array_push($wp_cache_meta_object->headers, "$key: " . $response[$key]);
326
  }
327
  }
328
  /* Not used because it gives problems with some
334
  array_push($wp_cache_meta_object->headers, "Content-Length: $content_size");
335
  }
336
  */
337
+ if (!isset( $response['Last-Modified'] )) {
338
  $value = gmdate('D, d M Y H:i:s') . ' GMT';
339
  /* Dont send this the first time */
340
  /* @header('Last-Modified: ' . $value); */
341
  array_push($wp_cache_meta_object->headers, "Last-Modified: $value");
342
  }
343
+ if (!$response['Content-Type'] && !$response['Content-type']) {
344
  // On some systems, headers set by PHP can't be fetched from
345
  // the output buffer. This is a last ditch effort to set the
346
  // correct Content-Type header for feeds, if we didn't see
369
  array_push($wp_cache_meta_object->headers, "Content-Type: $value");
370
  }
371
 
372
+ @ob_end_flush();
373
  if ($new_cache) {
374
  $serial = serialize($wp_cache_meta_object);
375
  if( !wp_cache_writers_entry() )
383
  wp_cache_writers_exit();
384
  }
385
 
386
+ if( !isset( $wp_cache_gc ) )
387
+ $wp_cache_gc = 100;
388
+ if( mt_rand( 0, $wp_cache_gc ) != 1 )
389
  return;
390
 
391
  // we delete expired files
437
  @unlink( $cache_file );
438
  @unlink( $cache_file . '.gz' );
439
  }
440
+ prune_super_cache( $dir . $permalink, true ); // remove pages under permalink.
441
  }
442
  }
443
 
481
  if ($post_ID > 0 ) return $post_ID;
482
  if ($comment_post_ID > 0 ) return $comment_post_ID;
483
  if (is_single() || is_page()) return $posts[0]->ID;
484
+ if (isset( $_GET[ 'p' ] ) && $_GET['p'] > 0) return $_GET['p'];
485
+ if (isset( $_POST[ 'p' ] ) && $_POST['p'] > 0) return $_POST['p'];
486
  return 0;
487
  }
488
  ?>
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 enabled, you must <a href="options-general.php?page=wp-super-cache/wp-cache.php">enable the cache</a>. Based on WP-Cache by <a href="http://mnm.uib.es/gallir/">Ricardo Galli Granada</a>.
6
- Version: 0.6.4
7
  Author: Donncha O Caoimh
8
  Author URI: http://ocaoimh.ie/
9
  */
@@ -131,19 +131,25 @@ function toggleLayer( whichLayer ) {
131
  <p>It appears that mod_rewrite is not installed. Sometimes this check isn't 100% reliable, especially if you are not using Apache. Please verify that the mod_rewrite module is loaded. It is required for serving Super Cache static files. You will still be able to use WP-Cache.</p><?php
132
  }
133
 
134
- if( !is_writeable( ABSPATH . 'wp-content/' ) || !is_writable($wp_cache_config_file) ) {
135
  define( "SUBMITDISABLED", 'disabled style="color: #aaa" ' );
136
- ?><h4 style='color: #a00'>Read Only Mode. Configuration cannot be changed. <a href="javascript:toggleLayer('readonlywarning');" title="Why your configuration may not be changed">Why</a></h4>
137
  <div id='readonlywarning' style='border: 1px solid #aaa; margin: 2px; padding: 2px; display: none;'>
138
- <p>The WP Super Cache configuration file is <code><?php echo ABSPATH ?>wp-content/wp-cache-config.php</code> and cannot be modified. The wp-content directory and wp-cache-config.php file must be writeable by the webserver to make any changes.<br />
139
  A simple way of doing that is by changing the permissions temporarily using the CHMOD command or through your ftp client. Make sure it's globally writeable and it should be fine.<br />
140
- Writeable: <code>chmod 777 wp-content; chmod 666 wp-content/wp-cache-config.php</code><br />
141
- Readonly: <code>chmod 755 wp-content; chmod 644 wp-content/wp-cache-config.php</code></p>
142
  </div><?php
143
  } else {
144
  define( "SUBMITDISABLED", ' ' );
145
  }
146
 
 
 
 
 
 
 
147
  if ( $valid_nonce ) {
148
  if( isset( $_POST[ 'wp_cache_status' ] ) ) {
149
  switch( $_POST[ 'wp_cache_status' ] ) {
@@ -240,6 +246,7 @@ function toggleLayer( whichLayer ) {
240
  $rules .= "RewriteCond %{REQUEST_METHOD} !=POST\n";
241
  $rules .= "RewriteCond %{QUERY_STRING} !.*s=.*\n";
242
  $rules .= "RewriteCond %{QUERY_STRING} !.*attachment_id=.*\n";
 
243
  $rules .= "RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$\n";
244
  $rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n";
245
  $rules .= "RewriteCond %{DOCUMENT_ROOT}{$home_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html.gz -f\n";
@@ -248,6 +255,7 @@ function toggleLayer( whichLayer ) {
248
  $rules .= "RewriteCond %{REQUEST_METHOD} !=POST\n";
249
  $rules .= "RewriteCond %{QUERY_STRING} !.*s=.*\n";
250
  $rules .= "RewriteCond %{QUERY_STRING} !.*attachment_id=.*\n";
 
251
  $rules .= "RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$\n";
252
  $rules .= "RewriteCond %{DOCUMENT_ROOT}{$home_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html -f\n";
253
  $rules .= "RewriteRule ^(.*) {$home_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html [L]\n";
@@ -506,7 +514,7 @@ function RecursiveFolderDelete ( $folderPath ) { // from http://www.php.net/manu
506
  }
507
 
508
  function wp_cache_edit_max_time () {
509
- global $super_cache_max_time, $cache_max_time, $wp_cache_config_file, $valid_nonce, $cache_enabled, $super_cache_enabled;
510
 
511
  if( !isset( $super_cache_max_time ) )
512
  $super_cache_max_time = 21600;
@@ -525,6 +533,10 @@ function wp_cache_edit_max_time () {
525
  wp_cache_replace_line('^ *\$super_cache_max_time', "\$super_cache_max_time = $super_cache_max_time;", $wp_cache_config_file);
526
  }
527
  }
 
 
 
 
528
  ?><br /><fieldset style='border: 1px solid #aaa' class="options">
529
  <legend>Expiry Time</legend><?php
530
  echo '<form name="wp_edit_max_time" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
@@ -534,6 +546,15 @@ function wp_cache_edit_max_time () {
534
  echo '<label for="super_cache_max_time">Super Cache Expire time:</label> ';
535
  echo "<input type=\"text\" size=6 name=\"super_cache_max_time\" value=\"$super_cache_max_time\" /> seconds";
536
  }
 
 
 
 
 
 
 
 
 
537
  echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="Change expiration &raquo;" /></div>';
538
  wp_nonce_field('wp-cache');
539
  echo "</form>\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 enabled, you must <a href="options-general.php?page=wp-super-cache/wp-cache.php">enable the cache</a>. Based on WP-Cache by <a href="http://mnm.uib.es/gallir/">Ricardo Galli Granada</a>.
6
+ Version: 0.6.5
7
  Author: Donncha O Caoimh
8
  Author URI: http://ocaoimh.ie/
9
  */
131
  <p>It appears that mod_rewrite is not installed. Sometimes this check isn't 100% reliable, especially if you are not using Apache. Please verify that the mod_rewrite module is loaded. It is required for serving Super Cache static files. You will still be able to use WP-Cache.</p><?php
132
  }
133
 
134
+ if( !is_writable($wp_cache_config_file) ) {
135
  define( "SUBMITDISABLED", 'disabled style="color: #aaa" ' );
136
+ ?><h4 style='text-align:center; color: #a00'>Read Only Mode. Configuration cannot be changed. <a href="javascript:toggleLayer('readonlywarning');" title="Why your configuration may not be changed">Why</a></h4>
137
  <div id='readonlywarning' style='border: 1px solid #aaa; margin: 2px; padding: 2px; display: none;'>
138
+ <p>The WP Super Cache configuration file is <code><?php echo ABSPATH ?>wp-content/wp-cache-config.php</code> and cannot be modified. The file wp-content/wp-cache-config.php must be writeable by the webserver to make any changes.<br />
139
  A simple way of doing that is by changing the permissions temporarily using the CHMOD command or through your ftp client. Make sure it's globally writeable and it should be fine.<br />
140
+ Writeable: <code>chmod 666 wp-content/wp-cache-config.php</code><br />
141
+ Readonly: <code>chmod 644 wp-content/wp-cache-config.php</code></p>
142
  </div><?php
143
  } else {
144
  define( "SUBMITDISABLED", ' ' );
145
  }
146
 
147
+ if( is_writable( ABSPATH . 'wp-content/' ) ) {
148
+ ?><h4 style='text-align:center; color: #a00'>Warning! wp-content is writeable!</h4>
149
+ <p>You should change the permissions on <?php echo ABSPATH; ?>wp-content/ and make it more restrictive. Use your ftp client, or the following command to fix things:<br /><code>chmod 755 <?php echo ABSPATH; ?>wp-content/</code></p><?php
150
+
151
+ }
152
+
153
  if ( $valid_nonce ) {
154
  if( isset( $_POST[ 'wp_cache_status' ] ) ) {
155
  switch( $_POST[ 'wp_cache_status' ] ) {
246
  $rules .= "RewriteCond %{REQUEST_METHOD} !=POST\n";
247
  $rules .= "RewriteCond %{QUERY_STRING} !.*s=.*\n";
248
  $rules .= "RewriteCond %{QUERY_STRING} !.*attachment_id=.*\n";
249
+ $rules .= "RewriteCond %{QUERY_STRING} !.*wp-subscription-manager=.*\n";
250
  $rules .= "RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$\n";
251
  $rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n";
252
  $rules .= "RewriteCond %{DOCUMENT_ROOT}{$home_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html.gz -f\n";
255
  $rules .= "RewriteCond %{REQUEST_METHOD} !=POST\n";
256
  $rules .= "RewriteCond %{QUERY_STRING} !.*s=.*\n";
257
  $rules .= "RewriteCond %{QUERY_STRING} !.*attachment_id=.*\n";
258
+ $rules .= "RewriteCond %{QUERY_STRING} !.*wp-subscription-manager=.*\n";
259
  $rules .= "RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$\n";
260
  $rules .= "RewriteCond %{DOCUMENT_ROOT}{$home_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html -f\n";
261
  $rules .= "RewriteRule ^(.*) {$home_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}$1/index.html [L]\n";
514
  }
515
 
516
  function wp_cache_edit_max_time () {
517
+ global $super_cache_max_time, $cache_max_time, $wp_cache_config_file, $valid_nonce, $cache_enabled, $super_cache_enabled, $wp_cache_gc;
518
 
519
  if( !isset( $super_cache_max_time ) )
520
  $super_cache_max_time = 21600;
533
  wp_cache_replace_line('^ *\$super_cache_max_time', "\$super_cache_max_time = $super_cache_max_time;", $wp_cache_config_file);
534
  }
535
  }
536
+ if(isset($_POST['wp_cache_gc']) && $valid_nonce) {
537
+ $wp_cache_gc = (int)$_POST['wp_cache_gc'];
538
+ wp_cache_replace_line('^ *\$wp_cache_gc', "\$wp_cache_gc = $wp_cache_gc;", $wp_cache_config_file);
539
+ }
540
  ?><br /><fieldset style='border: 1px solid #aaa' class="options">
541
  <legend>Expiry Time</legend><?php
542
  echo '<form name="wp_edit_max_time" action="'. $_SERVER["REQUEST_URI"] . '" method="post">';
546
  echo '<label for="super_cache_max_time">Super Cache Expire time:</label> ';
547
  echo "<input type=\"text\" size=6 name=\"super_cache_max_time\" value=\"$super_cache_max_time\" /> seconds";
548
  }
549
+ if( !isset( $wp_cache_gc ) )
550
+ $wp_cache_gc = 100;
551
+ echo "<h4>Garbage Collection</h4><p>How often should expired files be deleted? Once every:</p>";
552
+ echo "<ul><li><input type='radio' name='wp_cache_gc' value='100'" . ( $wp_cache_gc == 100 ? ' checked' : '' ) . " /> 100 requests (very often)</li>\n";
553
+ echo "<li><input type='radio' name='wp_cache_gc' value='500'" . ( $wp_cache_gc == 500 ? ' checked' : '' ) . " /> 500 requests</li>\n";
554
+ echo "<li><input type='radio' name='wp_cache_gc' value='1000'" . ( $wp_cache_gc == 1000 ? ' checked' : '' ) . " /> 1000 requests</li>\n";
555
+ echo "<li><input type='radio' name='wp_cache_gc' value='2000'" . ( $wp_cache_gc == 2000 ? ' checked' : '' ) . " /> 2000 requests</li>\n";
556
+ echo "<li><input type='radio' name='wp_cache_gc' value='5000'" . ( $wp_cache_gc == 5000 ? ' checked' : '' ) . " /> 5000 requests (very seldom)</li></ul>\n";
557
+ echo "<p>Checking for and deleting expired files is expensive, but it's expensive leaving them there too. On a very busy site you can leave this fairly high. Experiment with different values and visit this page to see how many expired files remain at different times during the day.</p><p>Simple rule of thumb: divide your number of daily page views by 5 and pick the closest number above.</p>";
558
  echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'value="Change expiration &raquo;" /></div>';
559
  wp_nonce_field('wp-cache');
560
  echo "</form>\n";