Hyper Cache - Version 1.1

Version Description

Download this release

Release Info

Developer satollo
Plugin Icon wp plugin Hyper Cache
Version 1.1
Comparing to
See all releases

Code changes from version 1.0.9 to 1.1

Files changed (4) hide show
  1. advanced-cache.php +56 -31
  2. options.php +4 -0
  3. plugin.php +5 -1
  4. readme.txt +1 -1
advanced-cache.php CHANGED
@@ -2,67 +2,65 @@
2
  @include( dirname(__FILE__) . '/hyper-cache-config.php' );
3
 
4
  // From the config file
5
- if (!$hyper_cache_enabled) {
6
- return false;
7
- }
8
 
9
  // Do not cache post request (comments, plugins and so on)
10
- if ($_SERVER["REQUEST_METHOD"] == 'POST') {
11
- return false;
12
- }
13
 
14
  // Do not use or cache pages when a wordpress user is logged on
15
  foreach ( (array) $_COOKIE as $n => $v ) {
16
  // wp 2.5 and wp 2.3 have different cookie prefix
17
- if (substr($n, 0, 14) == 'wordpressuser_' || substr($n, 0, 10) == 'wordpress_' ) {
18
- return false;
19
  }
20
  }
21
 
22
  $hyper_uri = stripslashes($_SERVER['REQUEST_URI']);
23
 
24
- if (!$hyper_cache_get && strpos($hyper_uri, '?') !== false) return false;
25
 
26
  // Do not cache WP pages, even if those calls typically don't go throught this script
27
  if (strpos($hyper_uri, '/wp-admin/') !== false ||
28
- strpos($hyper_uri, '/wp-includes/') !== false ||
29
- strpos($hyper_uri, '/wp-content/') !== false ) {
30
- return false;
31
  }
32
 
33
 
34
  // Special blocks: the download manager plugin
35
  /*
36
  if (strpos($hyper_uri, '/download/') !== false) {
37
- return false;
38
  }
39
  */
40
 
41
  // Remove the anchor
 
42
  $x = strpos($hyper_uri, '#');
43
  if ($x !== false) {
44
- $hyper_uri = substr($hyper_uri, 0, $x);
45
  }
 
46
 
47
  $hyper_cache_name = md5($hyper_uri);
48
  $hyper_file = ABSPATH . 'wp-content/hyper-cache/' . $hyper_cache_name . '.dat';
49
 
50
  if ( is_file($hyper_file) ) {
51
  $hyper_data = unserialize( file_get_contents($hyper_file) );
52
-
53
  // Default timeout
54
  if ($hyper_cache_timeout == null) {
55
- $hyper_cache_timeout = 60;
56
  }
57
-
58
  if ($hyper_data != null && ($hyper_data['time'] > time()-($hyper_cache_timeout*60)) && $hyper_data['html'] != '') {
59
- if ($hyper_data['mime'] == '')
60
- {
61
- header('Content-Type: text/html;charset=UTF-8');
62
- }
63
- else {
64
- header('Content-Type: ' . $hyper_data['mime']);
65
- }
66
  echo $hyper_data['html'];
67
  echo '<!-- hyper cache -->';
68
  flush();
@@ -73,22 +71,49 @@ if ( is_file($hyper_file) ) {
73
  // Now we start the caching, but we remove the cookie which stores the comment for data
74
  foreach ( (array) $_COOKIE as $n => $v ) {
75
  if (substr($n, 0, 14) == 'comment_author') {
76
- unset($_COOKIE[$n]);
77
  }
78
  }
79
 
80
  ob_start('hyper_cache_callback');
81
  function hyper_cache_callback($buffer) {
82
- global $hyper_file;
 
 
83
 
 
 
 
 
 
 
 
 
 
84
  $data['uri'] = $_SERVER['REQUEST_URI'];
85
  $data['referer'] = $_SERVER['HTTP_REFERER'];
86
  $data['time'] = time();
87
- if (is_feed()) {
88
- $data['mime'] = 'text/xml;charset=UTF-8';
89
- } else {
90
- $data['mime'] = 'text/html;charset=UTF-8';
91
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  $data['html'] = $buffer;
93
 
94
  $file = fopen($hyper_file, 'w');
2
  @include( dirname(__FILE__) . '/hyper-cache-config.php' );
3
 
4
  // From the config file
5
+ if (!$hyper_cache_enabled) return false;
 
 
6
 
7
  // Do not cache post request (comments, plugins and so on)
8
+ if ($_SERVER["REQUEST_METHOD"] == 'POST') return false;
 
 
9
 
10
  // Do not use or cache pages when a wordpress user is logged on
11
  foreach ( (array) $_COOKIE as $n => $v ) {
12
  // wp 2.5 and wp 2.3 have different cookie prefix
13
+ if (substr($n, 0, 14) == 'wordpressuser_' || substr($n, 0, 10) == 'wordpress_' || substr($n, 0, 12) == 'wp-postpass_') {
14
+ return false;
15
  }
16
  }
17
 
18
  $hyper_uri = stripslashes($_SERVER['REQUEST_URI']);
19
 
20
+ //if (!$hyper_cache_get && strpos($hyper_uri, '?') !== false) return false;
21
 
22
  // Do not cache WP pages, even if those calls typically don't go throught this script
23
  if (strpos($hyper_uri, '/wp-admin/') !== false ||
24
+ strpos($hyper_uri, '/wp-includes/') !== false ||
25
+ strpos($hyper_uri, '/wp-content/') !== false ) {
26
+ return false;
27
  }
28
 
29
 
30
  // Special blocks: the download manager plugin
31
  /*
32
  if (strpos($hyper_uri, '/download/') !== false) {
33
+ return false;
34
  }
35
  */
36
 
37
  // Remove the anchor
38
+ /*
39
  $x = strpos($hyper_uri, '#');
40
  if ($x !== false) {
41
+ $hyper_uri = substr($hyper_uri, 0, $x);
42
  }
43
+ */
44
 
45
  $hyper_cache_name = md5($hyper_uri);
46
  $hyper_file = ABSPATH . 'wp-content/hyper-cache/' . $hyper_cache_name . '.dat';
47
 
48
  if ( is_file($hyper_file) ) {
49
  $hyper_data = unserialize( file_get_contents($hyper_file) );
50
+
51
  // Default timeout
52
  if ($hyper_cache_timeout == null) {
53
+ $hyper_cache_timeout = 60;
54
  }
55
+
56
  if ($hyper_data != null && ($hyper_data['time'] > time()-($hyper_cache_timeout*60)) && $hyper_data['html'] != '') {
57
+ if ($hyper_data['mime'] == '')
58
+ {
59
+ header('Content-Type: text/html;charset=UTF-8');
60
+ }
61
+ else {
62
+ header('Content-Type: ' . $hyper_data['mime']);
63
+ }
64
  echo $hyper_data['html'];
65
  echo '<!-- hyper cache -->';
66
  flush();
71
  // Now we start the caching, but we remove the cookie which stores the comment for data
72
  foreach ( (array) $_COOKIE as $n => $v ) {
73
  if (substr($n, 0, 14) == 'comment_author') {
74
+ unset($_COOKIE[$n]);
75
  }
76
  }
77
 
78
  ob_start('hyper_cache_callback');
79
  function hyper_cache_callback($buffer) {
80
+ global $hyper_file, $hyper_compress, $post;
81
+
82
+ if (strlen($buffer) == 0) return '';
83
 
84
+ // Check for password posts -- do not cache
85
+ /*
86
+ rewind_posts();
87
+ while (have_posts())
88
+ {
89
+ the_post();
90
+ if (!empty($post->post_password)) return $buffer;
91
+ }
92
+ */
93
  $data['uri'] = $_SERVER['REQUEST_URI'];
94
  $data['referer'] = $_SERVER['HTTP_REFERER'];
95
  $data['time'] = time();
96
+ if (is_feed()) {
97
+ $data['mime'] = 'text/xml;charset=UTF-8';
98
+ } else {
99
+ $data['mime'] = 'text/html;charset=UTF-8';
100
+ }
101
+ if ($hyper_compress)
102
+ {
103
+ $buffer = ereg_replace("[ \t]+", ' ', $buffer);
104
+ $buffer = ereg_replace("[\r\n]", "\n", $buffer);
105
+ $buffer = ereg_replace(" *\n *", "\n", $buffer);
106
+ $buffer = ereg_replace("\n+", "\n", $buffer);
107
+ $buffer = ereg_replace("\" />", "\"/>", $buffer);
108
+ $buffer = ereg_replace("<tr>\n", "<tr>", $buffer);
109
+ $buffer = ereg_replace("<td>\n", "<td>", $buffer);
110
+ $buffer = ereg_replace("<ul>\n", "<ul>", $buffer);
111
+ $buffer = ereg_replace("</ul>\n", "</ul>", $buffer);
112
+ $buffer = ereg_replace("<p>\n", "<p>", $buffer);
113
+ $buffer = ereg_replace("</p>\n", "</p>", $buffer);
114
+ $buffer = ereg_replace("</li>\n", "</li>", $buffer);
115
+ $buffer = ereg_replace("</td>\n", "</td>", $buffer);
116
+ }
117
  $data['html'] = $buffer;
118
 
119
  $file = fopen($hyper_file, 'w');
options.php CHANGED
@@ -70,6 +70,7 @@ if (isset($_POST['save'])) {
70
 
71
  $buffer = "<?php\n";
72
  $buffer .= '$hyper_cache_enabled = ' . ($options['cache']?'true':'false') . ";\n";
 
73
  $buffer .= '$hyper_cache_timeout = ' . $options['timeout'] . ";\n";
74
  $buffer .= '$hyper_cache_get = ' . ($options['get']?'true':'false') . ";\n";
75
  $buffer .= '?>';
@@ -112,6 +113,9 @@ else
112
  <tr valign="top">
113
  <?php hyper_field_checkbox('not_expire_on_actions', __('not_expire_on_actions', 'hyper-cache'), __('not_expire_on_actions_desc', 'hyper-cache'), 'size="5"'); ?>
114
  </tr>
 
 
 
115
 
116
  <tr valign="top">
117
  <th scope="row"><?php _e('count', 'hyper-cache'); ?></th>
70
 
71
  $buffer = "<?php\n";
72
  $buffer .= '$hyper_cache_enabled = ' . ($options['cache']?'true':'false') . ";\n";
73
+ $buffer .= '$hyper_compress = ' . ($options['compress']?'true':'false') . ";\n";
74
  $buffer .= '$hyper_cache_timeout = ' . $options['timeout'] . ";\n";
75
  $buffer .= '$hyper_cache_get = ' . ($options['get']?'true':'false') . ";\n";
76
  $buffer .= '?>';
113
  <tr valign="top">
114
  <?php hyper_field_checkbox('not_expire_on_actions', __('not_expire_on_actions', 'hyper-cache'), __('not_expire_on_actions_desc', 'hyper-cache'), 'size="5"'); ?>
115
  </tr>
116
+ <tr valign="top">
117
+ <?php hyper_field_checkbox('compress', __('compress_html', 'hyper-cache')); ?>
118
+ </tr>
119
 
120
  <tr valign="top">
121
  <th scope="row"><?php _e('count', 'hyper-cache'); ?></th>
plugin.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Hyper Cache
4
  Plugin URI: http://www.satollo.com/english/wordpress/hyper-cache
5
  Description: Hyper Cache is an extremely aggressive cache for WordPress.
6
- Version: 1.0.9
7
  Author: Satollo
8
  Author URI: http://www.satollo.com
9
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
@@ -29,6 +29,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
  ---
30
  Changelog
31
  ---
 
 
 
 
32
  Verison 1.0.9
33
  - fixed a bug in the "not expire" management
34
 
3
  Plugin Name: Hyper Cache
4
  Plugin URI: http://www.satollo.com/english/wordpress/hyper-cache
5
  Description: Hyper Cache is an extremely aggressive cache for WordPress.
6
+ Version: 1.1
7
  Author: Satollo
8
  Author URI: http://www.satollo.com
9
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
29
  ---
30
  Changelog
31
  ---
32
+ Version 1.1
33
+ - fixed behaviour with password protected posts
34
+ - added a bit of html compression (not gzip)
35
+
36
  Verison 1.0.9
37
  - fixed a bug in the "not expire" management
38
 
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Tags: cache,chaching
3
  Requires at least: 2.1
4
  Tested up to: 2.5.1
5
- Stable tag: 1.0.9
6
  Donate link: http://www.satollo.com/english/donate
7
  Contributors: satollo,momo360modena
8
 
2
  Tags: cache,chaching
3
  Requires at least: 2.1
4
  Tested up to: 2.5.1
5
+ Stable tag: 1.1
6
  Donate link: http://www.satollo.com/english/donate
7
  Contributors: satollo,momo360modena
8