Hyper Cache - Version 1.2.6

Version Description

Download this release

Release Info

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

Code changes from version 1.2.5 to 1.2.6

Files changed (8) hide show
  1. advanced-cache.php +76 -55
  2. de_DE.php +1 -1
  3. en_US.php +3 -1
  4. fr_FR.php +1 -1
  5. it_IT.php +1 -1
  6. options.php +6 -2
  7. plugin.php +5 -6
  8. readme.txt +1 -1
advanced-cache.php CHANGED
@@ -17,7 +17,7 @@ foreach ($_COOKIE as $n=>$v)
17
  }
18
  }
19
 
20
- $hyper_uri = stripslashes($_SERVER['REQUEST_URI']);
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 || strpos($hyper_uri, '/wp-includes/') !== false || strpos($hyper_uri, '/wp-content/') !== false )
@@ -25,6 +25,8 @@ if (strpos($hyper_uri, '/wp-admin/') !== false || strpos($hyper_uri, '/wp-includ
25
  return false;
26
  }
27
 
 
 
28
  // The name of the file with html and other data
29
  $hyper_cache_name = md5($hyper_uri);
30
  $hyper_file = ABSPATH . 'wp-content/hyper-cache/' . $hyper_cache_name . '.dat';
@@ -91,76 +93,95 @@ ob_start('hyper_cache_callback');
91
  // Called whenever the page generation is ended
92
  function hyper_cache_callback($buffer)
93
  {
94
- global $hyper_redirect, $hyper_file, $hyper_compress, $post, $hyper_cache_name, $hyper_cache_gzip;
 
 
 
 
 
 
 
 
 
 
 
95
 
96
- // A bug? May be WP call the "canonical_redirect" hook even when no redirect is really issued. If the
97
- // uri equals the WP redirect, we ignore it.
98
- if ($hyper_redirect == $_SERVER['REQUEST_URI']) $hyper_redirect = null;
99
 
100
- if (!$hyper_redirect && strlen($buffer) == 0) return '';
 
101
 
102
- $data['uri'] = $_SERVER['REQUEST_URI'];
103
- $data['referer'] = $_SERVER['HTTP_REFERER'];
104
- $data['time'] = time();
105
- if (false && $hyper_redirect)
106
  {
107
- $data['location'] = $hyper_redirect;
108
- }
109
  else
110
  {
111
- if (is_feed())
112
- {
113
- $data['mime'] = 'text/xml;charset=UTF-8';
114
- }
115
- else
116
- {
117
- $data['mime'] = 'text/html;charset=UTF-8';
118
- }
119
 
120
- // Clean up a it the html, this is a energy saver plugin!
121
- if ($hyper_compress)
122
- {
123
- $buffer = ereg_replace("[ \t]+", ' ', $buffer);
124
- $buffer = ereg_replace("[\r\n]", "\n", $buffer);
125
- $buffer = ereg_replace(" *\n *", "\n", $buffer);
126
- $buffer = ereg_replace("\n+", "\n", $buffer);
127
- $buffer = ereg_replace("\" />", "\"/>", $buffer);
128
- $buffer = ereg_replace("<tr>\n", "<tr>", $buffer);
129
- $buffer = ereg_replace("<td>\n", "<td>", $buffer);
130
- $buffer = ereg_replace("<ul>\n", "<ul>", $buffer);
131
- $buffer = ereg_replace("</ul>\n", "</ul>", $buffer);
132
- $buffer = ereg_replace("<p>\n", "<p>", $buffer);
133
- $buffer = ereg_replace("</p>\n", "</p>", $buffer);
134
- $buffer = ereg_replace("</li>\n", "</li>", $buffer);
135
- $buffer = ereg_replace("</td>\n", "</td>", $buffer);
136
- }
137
- $buffer .= '<!-- hyper cache: ' . $hyper_cache_name . ' -->';
138
- $data['html'] = $buffer;
139
- if ($hyper_cache_gzip && function_exists('gzencode'))
140
- {
141
- $data['gz'] = gzencode($buffer);
142
- }
143
 
144
- if (is_404())
 
 
145
  {
146
- if (!file_exists(ABSPATH . 'wp-content/hyper-cache/404.dat'))
147
- {
148
- $file = fopen(ABSPATH . 'wp-content/hyper-cache/404.dat', 'w');
149
- fwrite($file, serialize($data));
150
- fclose($file);
151
- }
152
- unset($data['html']);
153
- unset($data['gz']);
154
- $data['status'] = 404;
155
  }
156
-
 
 
157
  }
158
 
 
 
 
 
159
 
 
 
 
 
 
 
 
 
160
 
161
  $file = fopen($hyper_file, 'w');
162
  fwrite($file, serialize($data));
163
- fclose($file);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
  return $buffer;
166
  }
17
  }
18
  }
19
 
20
+ $hyper_uri = $_SERVER['REQUEST_URI'];
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 || strpos($hyper_uri, '/wp-includes/') !== false || strpos($hyper_uri, '/wp-content/') !== false )
25
  return false;
26
  }
27
 
28
+ //$hyper_uri = $_SERVER['HTTP_HOST'] . $hyper_uri;
29
+
30
  // The name of the file with html and other data
31
  $hyper_cache_name = md5($hyper_uri);
32
  $hyper_file = ABSPATH . 'wp-content/hyper-cache/' . $hyper_cache_name . '.dat';
93
  // Called whenever the page generation is ended
94
  function hyper_cache_callback($buffer)
95
  {
96
+ global $hyper_cache_redirects, $hyper_redirect, $hyper_file, $hyper_cache_compress, $hyper_cache_name, $hyper_cache_gzip;
97
+
98
+ // WP is sending a redirect
99
+ if ($hyper_redirect)
100
+ {
101
+ if ($hyper_cache_redirects)
102
+ {
103
+ $data['location'] = $hyper_redirect;
104
+ hyper_cache_write($data);
105
+ }
106
+ return $buffer;
107
+ }
108
 
109
+ $buffer = trim($buffer);
 
 
110
 
111
+ // Can be a trackback or other things without a body. We do not cache them, WP needs to get those calls.
112
+ if (strlen($buffer) == 0) return '';
113
 
114
+ if (is_feed())
 
 
 
115
  {
116
+ $data['mime'] = 'text/xml;charset=UTF-8';
117
+ }
118
  else
119
  {
120
+ $data['mime'] = 'text/html;charset=UTF-8';
121
+ }
 
 
 
 
 
 
122
 
123
+ // Clean up a it the html, this is a energy saver plugin!
124
+ if ($hyper_cache_compress)
125
+ {
126
+ $buffer = hyper_cache_compress($buffer);
127
+ }
128
+
129
+ $buffer .= '<!-- hyper cache: ' . $hyper_cache_name . ' -->';
130
+
131
+ $data['html'] = $buffer;
132
+
133
+ if ($hyper_cache_gzip && function_exists('gzencode'))
134
+ {
135
+ $data['gz'] = gzencode($buffer);
136
+ }
 
 
 
 
 
 
 
 
 
137
 
138
+ if (is_404())
139
+ {
140
+ if (!file_exists(ABSPATH . 'wp-content/hyper-cache/404.dat'))
141
  {
142
+ $file = fopen(ABSPATH . 'wp-content/hyper-cache/404.dat', 'w');
143
+ fwrite($file, serialize($data));
144
+ fclose($file);
 
 
 
 
 
 
145
  }
146
+ unset($data['html']);
147
+ unset($data['gz']);
148
+ $data['status'] = 404;
149
  }
150
 
151
+ hyper_cache_write($data);
152
+
153
+ return $buffer;
154
+ }
155
 
156
+ function hyper_cache_write(&$data)
157
+ {
158
+ global $hyper_file;
159
+
160
+ $data['uri'] = $_SERVER['REQUEST_URI'];
161
+ $data['referer'] = $_SERVER['HTTP_REFERER'];
162
+ $data['time'] = time();
163
+ $data['host'] = $_SERVER['HTTP_HOST'];
164
 
165
  $file = fopen($hyper_file, 'w');
166
  fwrite($file, serialize($data));
167
+ fclose($file);
168
+ }
169
+
170
+ function hyper_cache_compress(&$buffer)
171
+ {
172
+ $buffer = ereg_replace("[ \t]+", ' ', $buffer);
173
+ $buffer = ereg_replace("[\r\n]", "\n", $buffer);
174
+ $buffer = ereg_replace(" *\n *", "\n", $buffer);
175
+ $buffer = ereg_replace("\n+", "\n", $buffer);
176
+ $buffer = ereg_replace("\" />", "\"/>", $buffer);
177
+ $buffer = ereg_replace("<tr>\n", "<tr>", $buffer);
178
+ $buffer = ereg_replace("<td>\n", "<td>", $buffer);
179
+ $buffer = ereg_replace("<ul>\n", "<ul>", $buffer);
180
+ $buffer = ereg_replace("</ul>\n", "</ul>", $buffer);
181
+ $buffer = ereg_replace("<p>\n", "<p>", $buffer);
182
+ $buffer = ereg_replace("</p>\n", "</p>", $buffer);
183
+ $buffer = ereg_replace("</li>\n", "</li>", $buffer);
184
+ $buffer = ereg_replace("</td>\n", "</td>", $buffer);
185
 
186
  return $buffer;
187
  }
de_DE.php CHANGED
@@ -1,4 +1,4 @@
1
- <?
2
 
3
  $hyper_labels['wp_cache_not_enabled'] = "Das WordPress Cachesystem ist nicht aktiv. Um es zu aktivieren bitte die folgende Zeile Code der Datei wp-config.php hinzuf&uuml;gen. Danke!";
4
  $hyper_labels['configuration'] = "Konfiguration";
1
+ <?php
2
 
3
  $hyper_labels['wp_cache_not_enabled'] = "Das WordPress Cachesystem ist nicht aktiv. Um es zu aktivieren bitte die folgende Zeile Code der Datei wp-config.php hinzuf&uuml;gen. Danke!";
4
  $hyper_labels['configuration'] = "Konfiguration";
en_US.php CHANGED
@@ -1,4 +1,4 @@
1
- <?
2
 
3
  $hyper_labels['wp_cache_not_enabled'] = "The wordPress cache system is not enabled. Please, activate it adding the line of code below in the file wp-config.php. Thank you!";
4
  $hyper_labels['configuration'] = "Configuration";
@@ -16,5 +16,7 @@ $hyper_labels['compress_html'] = "Optimize HTML";
16
  $hyper_labels['compress_html_desc'] = "Try to optimize the HTML removing unuseful spaces. Do not use if you are usgin &lt;pre&gt; tags in the posts";
17
  $hyper_labels['never_expire'] = "Never expire";
18
  $hyper_labels['never_expire_desc'] = "Do not expire the cache on actions, check only the cache timeout";
 
 
19
 
20
  ?>
1
+ <?php
2
 
3
  $hyper_labels['wp_cache_not_enabled'] = "The wordPress cache system is not enabled. Please, activate it adding the line of code below in the file wp-config.php. Thank you!";
4
  $hyper_labels['configuration'] = "Configuration";
16
  $hyper_labels['compress_html_desc'] = "Try to optimize the HTML removing unuseful spaces. Do not use if you are usgin &lt;pre&gt; tags in the posts";
17
  $hyper_labels['never_expire'] = "Never expire";
18
  $hyper_labels['never_expire_desc'] = "Do not expire the cache on actions, check only the cache timeout";
19
+ $hyper_labels['redirects'] = "Cache the WP redirects";
20
+ $hyper_labels['redirects_desc'] = "***DOT NOT USE*** when you have more than one host name, like www.domain.com and domain.com and are leaving WP to manage the redirects.";
21
 
22
  ?>
fr_FR.php CHANGED
@@ -1,4 +1,4 @@
1
- <?
2
 
3
  $hyper_labels['wp_cache_not_enabled'] = "Le cache de WordPress n'est pas activ&eacute;. Merci d'ajouter la ligne suivante dans votre fichier wp-config.php. Merci !";
4
  $hyper_labels['configuration'] = "Configuration";
1
+ <?php
2
 
3
  $hyper_labels['wp_cache_not_enabled'] = "Le cache de WordPress n'est pas activ&eacute;. Merci d'ajouter la ligne suivante dans votre fichier wp-config.php. Merci !";
4
  $hyper_labels['configuration'] = "Configuration";
it_IT.php CHANGED
@@ -1,4 +1,4 @@
1
- <?
2
 
3
  $hyper_labels['wp_cache_not_enabled'] = "Il sistema di caching di WordPress non &egrave; attivo. Attivarlo inserendo la riga sotto nel file wp-config.php. Grazie!";
4
  $hyper_labels['configuration'] = "Configurazione";
1
+ <?php
2
 
3
  $hyper_labels['wp_cache_not_enabled'] = "Il sistema di caching di WordPress non &egrave; attivo. Attivarlo inserendo la riga sotto nel file wp-config.php. Grazie!";
4
  $hyper_labels['configuration'] = "Configurazione";
options.php CHANGED
@@ -76,10 +76,11 @@ if (isset($_POST['save'])) {
76
 
77
  $buffer = "<?php\n";
78
  $buffer .= '$hyper_cache_enabled = ' . ($options['cache']?'true':'false') . ";\n";
79
- $buffer .= '$hyper_compress = ' . ($options['compress']?'true':'false') . ";\n";
80
  $buffer .= '$hyper_cache_timeout = ' . $options['timeout'] . ";\n";
81
  $buffer .= '$hyper_cache_get = ' . ($options['get']?'true':'false') . ";\n";
82
  $buffer .= '$hyper_cache_gzip = ' . ($options['gzip']?'true':'false') . ";\n";
 
83
  $buffer .= '?>';
84
  $file = fopen(ABSPATH . 'wp-content/hyper-cache-config.php', 'w');
85
  fwrite($file, $buffer);
@@ -128,7 +129,10 @@ else
128
  </tr>
129
  <tr valign="top">
130
  <?php hyper_field_checkbox('gzip', $hyper_labels['gzip_compression'], $hyper_labels['gzip_compression_desc']); ?>
131
- </tr>
 
 
 
132
 
133
  <tr valign="top">
134
  <th scope="row"><?php echo $hyper_labels['count']; ?></th>
76
 
77
  $buffer = "<?php\n";
78
  $buffer .= '$hyper_cache_enabled = ' . ($options['cache']?'true':'false') . ";\n";
79
+ $buffer .= '$hyper_cache_compress = ' . ($options['compress']?'true':'false') . ";\n";
80
  $buffer .= '$hyper_cache_timeout = ' . $options['timeout'] . ";\n";
81
  $buffer .= '$hyper_cache_get = ' . ($options['get']?'true':'false') . ";\n";
82
  $buffer .= '$hyper_cache_gzip = ' . ($options['gzip']?'true':'false') . ";\n";
83
+ $buffer .= '$hyper_cache_redirects = ' . ($options['redirects']?'true':'false') . ";\n";
84
  $buffer .= '?>';
85
  $file = fopen(ABSPATH . 'wp-content/hyper-cache-config.php', 'w');
86
  fwrite($file, $buffer);
129
  </tr>
130
  <tr valign="top">
131
  <?php hyper_field_checkbox('gzip', $hyper_labels['gzip_compression'], $hyper_labels['gzip_compression_desc']); ?>
132
+ </tr>
133
+ <tr valign="top">
134
+ <?php hyper_field_checkbox('redirects', $hyper_labels['redirects'], $hyper_labels['redirects_desc']); ?>
135
+ </tr>
136
 
137
  <tr valign="top">
138
  <th scope="row"><?php echo $hyper_labels['count']; ?></th>
plugin.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
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.2.5
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,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
  ---
30
  Changelog
31
  ---
 
32
  Version 1.2.x
33
  - new version with many improvements, maybe not very safe
34
 
@@ -219,10 +220,8 @@ $hyper_redirect = null;
219
  function hyper_redirect_canonical($redirect_url, $requested_url)
220
  {
221
  global $hyper_redirect;
222
- if ($redirect_url != $requested_url)
223
- {
224
- $hyper_redirect = $redirect_url;
225
- }
226
 
227
  return $redirect_url;
228
  }
2
  /*
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. After an upgrade, DEACTIVATE and REACTIVATE the plugin.
6
+ Version: 1.2.6
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
+
33
  Version 1.2.x
34
  - new version with many improvements, maybe not very safe
35
 
220
  function hyper_redirect_canonical($redirect_url, $requested_url)
221
  {
222
  global $hyper_redirect;
223
+
224
+ $hyper_redirect = $redirect_url;
 
 
225
 
226
  return $redirect_url;
227
  }
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Tags: cache,chaching
3
  Requires at least: 2.1
4
  Tested up to: 2.6.2
5
- Stable tag: 1.2.5
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.6.2
5
+ Stable tag: 1.2.6
6
  Donate link: http://www.satollo.com/english/donate
7
  Contributors: satollo,momo360modena
8