Version Description
- Small improvement on 404 caching
- General compatibility check with latest WP
Download this release
Release Info
Developer | satollo |
Plugin | Hyper Cache |
Version | 3.3.8 |
Comparing to | |
See all releases |
Code changes from version 3.3.7 to 3.3.8
- advanced-cache.php +24 -22
- options.php +72 -120
- plugin.php +81 -73
- readme.txt +7 -2
advanced-cache.php
CHANGED
@@ -14,7 +14,7 @@ if (defined('HYPER_CACHE_IS_MOBILE')) {
|
|
14 |
|
15 |
$hyper_cache_gzip_accepted = isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false;
|
16 |
|
17 |
-
$hyper_cache_is_bot = preg_match('#(googlebot)#i', $_SERVER['HTTP_USER_AGENT']);
|
18 |
|
19 |
if (HC_MOBILE === 2 && $hyper_cache_is_mobile) {
|
20 |
hyper_cache_header('stop - mobile');
|
@@ -23,12 +23,13 @@ if (HC_MOBILE === 2 && $hyper_cache_is_mobile) {
|
|
23 |
}
|
24 |
|
25 |
// Use this only if you can't or don't want to modify the .htaccess
|
26 |
-
if ($_SERVER['REQUEST_METHOD']
|
|
|
27 |
$cache_stop = true;
|
28 |
return false;
|
29 |
}
|
30 |
|
31 |
-
if ($_SERVER['QUERY_STRING']
|
32 |
hyper_cache_header('stop - query string');
|
33 |
$cache_stop = true;
|
34 |
return false;
|
@@ -39,25 +40,26 @@ if (defined('SID') && SID != '') {
|
|
39 |
return false;
|
40 |
}
|
41 |
|
42 |
-
if (
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
}
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
}
|
54 |
}
|
55 |
|
|
|
56 |
// Used globally
|
57 |
$hyper_cache_is_ssl = false;
|
58 |
|
|
|
59 |
if (isset($_SERVER['HTTPS'])) {
|
60 |
-
|
|
|
61 |
$hyper_cache_is_ssl = true;
|
62 |
} else if (isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] )) {
|
63 |
$hyper_cache_is_ssl = true;
|
@@ -72,7 +74,7 @@ if (HC_HTTPS === 0 && $hyper_cache_is_ssl) {
|
|
72 |
|
73 |
if (HC_REJECT_AGENTS_ENABLED && isset($_SERVER['HTTP_USER_AGENT'])) {
|
74 |
if (preg_match('#(HC_REJECT_AGENTS)#i', $_SERVER['HTTP_USER_AGENT'])) {
|
75 |
-
hyper_cache_header('stop - user agent');
|
76 |
$cache_stop = true;
|
77 |
return false;
|
78 |
}
|
@@ -97,9 +99,10 @@ if (!empty($_COOKIE)) {
|
|
97 |
$cache_stop = true;
|
98 |
return false;
|
99 |
}
|
|
|
100 |
if (HC_REJECT_COOKIES_ENABLED) {
|
101 |
if (preg_match('#(HC_REJECT_COOKIES)#i', $n)) {
|
102 |
-
hyper_cache_header('stop -
|
103 |
$cache_stop = true;
|
104 |
return false;
|
105 |
}
|
@@ -118,7 +121,6 @@ if (HC_MOBILE === 1 && $hyper_cache_is_mobile) {
|
|
118 |
$hyper_cache_group .= '-mobile';
|
119 |
}
|
120 |
|
121 |
-
//$hc_file = ABSPATH . 'wp-content/cache/lite-cache' . $_SERVER['REQUEST_URI'] . '/index' . $hc_group . '.html';
|
122 |
$hc_uri = hyper_cache_sanitize_uri($_SERVER['REQUEST_URI']);
|
123 |
$hc_host = hyper_cache_sanitize_host($_SERVER['HTTP_HOST']);
|
124 |
$hc_file = 'HC_FOLDER/' . $hc_host . $hc_uri . '/index' . $hyper_cache_group . '.html';
|
@@ -190,11 +192,11 @@ if ($hc_gzip) {
|
|
190 |
header('Content-Length: ' . filesize($hc_file));
|
191 |
}
|
192 |
|
193 |
-
if (HC_READFILE) {
|
194 |
readfile($hc_file);
|
195 |
-
} else {
|
196 |
-
echo file_get_contents($hc_file);
|
197 |
-
}
|
198 |
die();
|
199 |
|
200 |
function hyper_cache_sanitize_uri($uri) {
|
14 |
|
15 |
$hyper_cache_gzip_accepted = isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false;
|
16 |
|
17 |
+
$hyper_cache_is_bot = isset($_SERVER['HTTP_USER_AGENT']) && preg_match('#(googlebot)#i', $_SERVER['HTTP_USER_AGENT']);
|
18 |
|
19 |
if (HC_MOBILE === 2 && $hyper_cache_is_mobile) {
|
20 |
hyper_cache_header('stop - mobile');
|
23 |
}
|
24 |
|
25 |
// Use this only if you can't or don't want to modify the .htaccess
|
26 |
+
if ($_SERVER['REQUEST_METHOD'] != 'GET') {
|
27 |
+
hyper_cache_header('stop - non get');
|
28 |
$cache_stop = true;
|
29 |
return false;
|
30 |
}
|
31 |
|
32 |
+
if (!empty($_SERVER['QUERY_STRING'])) {
|
33 |
hyper_cache_header('stop - query string');
|
34 |
$cache_stop = true;
|
35 |
return false;
|
40 |
return false;
|
41 |
}
|
42 |
|
43 |
+
if (isset($_SERVER['HTTP_CACHE_CONTROL']) && $_SERVER['HTTP_CACHE_CONTROL'] == 'no-cache') {
|
44 |
+
hyper_cache_header('stop - no cache header');
|
45 |
+
$cache_stop = true;
|
46 |
+
return false;
|
47 |
+
}
|
|
|
48 |
|
49 |
+
if (isset($_SERVER['HTTP_PRAGMA']) && $_SERVER['HTTP_PRAGMA'] == 'no-cache') {
|
50 |
+
hyper_cache_header('stop - no cache header');
|
51 |
+
$cache_stop = true;
|
52 |
+
return false;
|
|
|
53 |
}
|
54 |
|
55 |
+
|
56 |
// Used globally
|
57 |
$hyper_cache_is_ssl = false;
|
58 |
|
59 |
+
// Copied from WP core
|
60 |
if (isset($_SERVER['HTTPS'])) {
|
61 |
+
$server_https = strtolower($_SERVER['HTTPS']);
|
62 |
+
if ('on' == $server_https || '1' == $server_https) {
|
63 |
$hyper_cache_is_ssl = true;
|
64 |
} else if (isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] )) {
|
65 |
$hyper_cache_is_ssl = true;
|
74 |
|
75 |
if (HC_REJECT_AGENTS_ENABLED && isset($_SERVER['HTTP_USER_AGENT'])) {
|
76 |
if (preg_match('#(HC_REJECT_AGENTS)#i', $_SERVER['HTTP_USER_AGENT'])) {
|
77 |
+
hyper_cache_header('stop - rejected user agent');
|
78 |
$cache_stop = true;
|
79 |
return false;
|
80 |
}
|
99 |
$cache_stop = true;
|
100 |
return false;
|
101 |
}
|
102 |
+
|
103 |
if (HC_REJECT_COOKIES_ENABLED) {
|
104 |
if (preg_match('#(HC_REJECT_COOKIES)#i', $n)) {
|
105 |
+
hyper_cache_header('stop - rejected cookie');
|
106 |
$cache_stop = true;
|
107 |
return false;
|
108 |
}
|
121 |
$hyper_cache_group .= '-mobile';
|
122 |
}
|
123 |
|
|
|
124 |
$hc_uri = hyper_cache_sanitize_uri($_SERVER['REQUEST_URI']);
|
125 |
$hc_host = hyper_cache_sanitize_host($_SERVER['HTTP_HOST']);
|
126 |
$hc_file = 'HC_FOLDER/' . $hc_host . $hc_uri . '/index' . $hyper_cache_group . '.html';
|
192 |
header('Content-Length: ' . filesize($hc_file));
|
193 |
}
|
194 |
|
195 |
+
//if (HC_READFILE) {
|
196 |
readfile($hc_file);
|
197 |
+
//} else {
|
198 |
+
// echo file_get_contents($hc_file);
|
199 |
+
//}
|
200 |
die();
|
201 |
|
202 |
function hyper_cache_sanitize_uri($uri) {
|
options.php
CHANGED
@@ -254,49 +254,7 @@ if (!wp_next_scheduled('hyper_cache_clean')) {
|
|
254 |
</div>
|
255 |
<?php } ?>
|
256 |
|
257 |
-
<div class="hc-box">
|
258 |
-
<h3>Your donation helps children</h3>
|
259 |
-
|
260 |
-
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5PHGDGNHAYLJ8" target="_blank"><img style="width: auto; height: auto;" src="<?php echo plugins_url('hyper-cache')?>/images/donation.png"></a>
|
261 |
-
|
262 |
-
<p>
|
263 |
-
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5PHGDGNHAYLJ8" target="_blank"><strong>Help children</strong> and support this plugin</a>. <a href="https://www.satollo.net/donations" target="_blank">Read more</a>.
|
264 |
-
</p>
|
265 |
-
</div>
|
266 |
-
<!--
|
267 |
-
<div class="hc-box">
|
268 |
-
<h3>Optimize your images with ShortPixel</h3>
|
269 |
-
|
270 |
-
<a href="https://www.satollo.net/affiliate/shortpixel" target="_blank"><img src="<?php echo plugins_url('hyper-cache')?>/images/shortpixel.png"></a>
|
271 |
-
|
272 |
-
<p>
|
273 |
-
<a href="https://www.satollo.net/affiliate/shortpixel" target="_blank">Don't lose the cache benefits serving oversized pictures (affiliate).</a>
|
274 |
-
</p>
|
275 |
-
</div>
|
276 |
-
-->
|
277 |
-
|
278 |
-
<div class="hc-box">
|
279 |
-
<h3>Is your site without a newsletter?</h3>
|
280 |
-
|
281 |
-
<a href="https://www.thenewsletterplugin.com/" target="_blank"><img src="<?php echo plugins_url('hyper-cache')?>/images/newsletter.png"></a>
|
282 |
-
|
283 |
-
<p>
|
284 |
-
<a href="https://www.thenewsletterplugin.com/" target="_blank">More than a newsletter is a mail marketing plugin (owner).</a>
|
285 |
-
</p>
|
286 |
-
</div>
|
287 |
-
|
288 |
-
<div class="hc-box">
|
289 |
-
<h3>CSS and JS optimization</h3>
|
290 |
-
|
291 |
-
<a href="https://it.wordpress.org/plugins/autoptimize/" target="_blank"><img src="<?php echo plugins_url('hyper-cache')?>/images/autoptimize.jpg"></a>
|
292 |
-
|
293 |
-
<p>
|
294 |
-
<a href="https://it.wordpress.org/plugins/autoptimize/" target="_blank">Rank high on Google Pagespeed (friend).</a>
|
295 |
-
</p>
|
296 |
-
</div>
|
297 |
-
|
298 |
|
299 |
-
<div style="clear: both"></div>
|
300 |
|
301 |
|
302 |
<?php $controls->show(); ?>
|
@@ -309,9 +267,11 @@ if (!wp_next_scheduled('hyper_cache_clean')) {
|
|
309 |
<p>
|
310 |
Please, refer to the <a href="https://www.satollo.net/plugins/hyper-cache" target="_blank">official page</a>
|
311 |
and the <a href="https://www.satollo.net/forums/forum/hyper-cache" target="_blank">official forum</a> for support.
|
312 |
-
|
|
|
313 |
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5PHGDGNHAYLJ8" target="_blank"><img style="vertical-align: bottom" src="https://www.satollo.net/images/donate.png"></a>
|
314 |
-
|
|
|
315 |
</p>
|
316 |
|
317 |
<p>
|
@@ -325,6 +285,7 @@ if (!wp_next_scheduled('hyper_cache_clean')) {
|
|
325 |
<li><a href="#tabs-general"><?php _e('General', 'hyper-cache'); ?></a></li>
|
326 |
<li><a href="#tabs-rejects"><?php _e('Bypasses', 'hyper-cache'); ?></a></li>
|
327 |
<li><a href="#tabs-mobile"><?php _e('Mobile', 'hyper-cache'); ?></a></li>
|
|
|
328 |
<li><a href="#tabs-cdn"><?php _e('CDN', 'hyper-cache'); ?></a></li>
|
329 |
</ul>
|
330 |
|
@@ -390,26 +351,8 @@ if (!wp_next_scheduled('hyper_cache_clean')) {
|
|
390 |
</p>
|
391 |
</td>
|
392 |
</tr>
|
393 |
-
|
394 |
-
|
395 |
-
<td>
|
396 |
-
<?php $controls->checkbox('gzip_on_the_fly'); ?>
|
397 |
-
|
398 |
-
<p class="description">
|
399 |
-
<?php _e('Enable on the fly compression for non cached pages.', 'hyper-cache'); ?>
|
400 |
-
</p>
|
401 |
-
</td>
|
402 |
-
</tr>
|
403 |
-
<tr>
|
404 |
-
|
405 |
-
<th><?php _e('When the home is refreshed, refresh even the', 'hyper-cache'); ?></th>
|
406 |
-
<td>
|
407 |
-
<?php $controls->text('clean_last_posts', 5); ?> <?php _e('latest post', 'hyper-cache'); ?>
|
408 |
-
<p class="description">
|
409 |
-
<?php _e('The number of latest posts to invalidate when the home is invalidated.', 'hyper-cache'); ?>
|
410 |
-
</p>
|
411 |
-
</td>
|
412 |
-
</tr>
|
413 |
|
414 |
<tr>
|
415 |
<th><?php _e('When a post is edited', 'hyper-cache'); ?></th>
|
@@ -423,41 +366,9 @@ if (!wp_next_scheduled('hyper_cache_clean')) {
|
|
423 |
</td>
|
424 |
</tr>
|
425 |
|
426 |
-
|
427 |
-
<th><?php _e('When a post receives a comment', 'hyper-cache'); ?></th>
|
428 |
-
<td>
|
429 |
-
<?php $controls->checkbox('clean_archives_on_comment'); ?> clean archives (categories, tags, ..., but not the home)
|
430 |
-
<br>
|
431 |
-
<?php $controls->checkbox('clean_home_on_comment'); ?> clean the home
|
432 |
-
<p class="description">
|
433 |
-
|
434 |
-
</p>
|
435 |
-
</td>
|
436 |
-
</tr>
|
437 |
-
|
438 |
-
<tr>
|
439 |
-
<th><?php _e('Cache folder', 'hyper-cache'); ?></th>
|
440 |
-
<td>
|
441 |
-
<?php if (defined('HYPER_CACHE_FOLDER')) { ?>
|
442 |
-
<?php _e('A custom cache folder is deinfed in wp-config.php', 'hyper-cache'); ?>: <code><?php echo esc_html(HYPER_CACHE_FOLDER)?></code>
|
443 |
-
<?php } else { ?>
|
444 |
-
<?php _e('A custom cache folder can be defined in wp-config.php', 'hyper-cache'); ?>
|
445 |
-
<code>define('HYPER_CACHE_FOLDER', '/path/to/cache/folder');</code>
|
446 |
-
<?php } ?>
|
447 |
-
</td>
|
448 |
-
</tr>
|
449 |
-
<tr>
|
450 |
-
<th><?php _e('Next autoclean will run in', 'hyper-cache'); ?></th>
|
451 |
-
<td>
|
452 |
-
<?php $controls->checkbox('autoclean', 'enable it'); ?>
|
453 |
|
454 |
-
|
455 |
-
<p class="description">
|
456 |
-
<?php _e('The autoclean process removes old files to save disk space.', 'hyper-cache'); ?>
|
457 |
-
<?php _e('If you enable the "serve expired pages to bots", you should disable the auto clean.', 'hyper-cache'); ?>
|
458 |
-
</p>
|
459 |
-
</td>
|
460 |
-
</tr>
|
461 |
<tr valign="top">
|
462 |
<th><?php _e('Allow browser caching', 'hyper-cache'); ?></th>
|
463 |
<td>
|
@@ -484,28 +395,7 @@ if (!wp_next_scheduled('hyper_cache_clean')) {
|
|
484 |
</td>
|
485 |
</tr>
|
486 |
|
487 |
-
|
488 |
-
<th><?php _e('Use readfile()', 'hyper-cache'); ?></th>
|
489 |
-
<td>
|
490 |
-
<?php $controls->checkbox('readfile', __('Enable', 'hyper-cache')); ?>
|
491 |
-
<p class="description">
|
492 |
-
<?php _e('Use the PHP function readfile() to send back a page.', 'hyper-cache'); ?>
|
493 |
-
<?php _e('It should be better than the file_get_contents() actually used.', 'hyper-cache'); ?>
|
494 |
-
</p>
|
495 |
-
</td>
|
496 |
-
</tr>
|
497 |
-
<!--
|
498 |
-
<tr>
|
499 |
-
<th><?php _e('Ignore no-cache header from bots', 'hyper-cache'); ?></th>
|
500 |
-
<td>
|
501 |
-
<?php $controls->checkbox('bots_ignore_nocache', __('Enable', 'hyper-cache')); ?>
|
502 |
-
<p class="description">
|
503 |
-
Bots usually send a no-cache request to ask always fresh pages. This option force the cache to
|
504 |
-
ignore such request and serve a caches page if available.
|
505 |
-
</p>
|
506 |
-
</td>
|
507 |
-
</tr>
|
508 |
-
-->
|
509 |
<tr>
|
510 |
<th><?php _e('Serve expired pages to bots', 'hyper-cache'); ?></th>
|
511 |
<td>
|
@@ -638,6 +528,68 @@ if (!wp_next_scheduled('hyper_cache_clean')) {
|
|
638 |
</tr>
|
639 |
</table>
|
640 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
641 |
|
642 |
<div id="tabs-mobile">
|
643 |
<table class="form-table">
|
254 |
</div>
|
255 |
<?php } ?>
|
256 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
|
|
|
258 |
|
259 |
|
260 |
<?php $controls->show(); ?>
|
267 |
<p>
|
268 |
Please, refer to the <a href="https://www.satollo.net/plugins/hyper-cache" target="_blank">official page</a>
|
269 |
and the <a href="https://www.satollo.net/forums/forum/hyper-cache" target="_blank">official forum</a> for support.
|
270 |
+
</p>
|
271 |
+
<p style="font-size: 1.2em; border: 1px solid #000; padding: 20px;">
|
272 |
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5PHGDGNHAYLJ8" target="_blank"><img style="vertical-align: bottom" src="https://www.satollo.net/images/donate.png"></a>
|
273 |
+
but before <a href="https://www.satollo.net/donations" target="_blank">read why this is a good thing</a>.
|
274 |
+
Even <b>2$</b> helps!
|
275 |
</p>
|
276 |
|
277 |
<p>
|
285 |
<li><a href="#tabs-general"><?php _e('General', 'hyper-cache'); ?></a></li>
|
286 |
<li><a href="#tabs-rejects"><?php _e('Bypasses', 'hyper-cache'); ?></a></li>
|
287 |
<li><a href="#tabs-mobile"><?php _e('Mobile', 'hyper-cache'); ?></a></li>
|
288 |
+
<li><a href="#tabs-advanced"><?php _e('Advanced', 'hyper-cache'); ?></a></li>
|
289 |
<li><a href="#tabs-cdn"><?php _e('CDN', 'hyper-cache'); ?></a></li>
|
290 |
</ul>
|
291 |
|
351 |
</p>
|
352 |
</td>
|
353 |
</tr>
|
354 |
+
|
355 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
356 |
|
357 |
<tr>
|
358 |
<th><?php _e('When a post is edited', 'hyper-cache'); ?></th>
|
366 |
</td>
|
367 |
</tr>
|
368 |
|
369 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
|
371 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
<tr valign="top">
|
373 |
<th><?php _e('Allow browser caching', 'hyper-cache'); ?></th>
|
374 |
<td>
|
395 |
</td>
|
396 |
</tr>
|
397 |
|
398 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
399 |
<tr>
|
400 |
<th><?php _e('Serve expired pages to bots', 'hyper-cache'); ?></th>
|
401 |
<td>
|
528 |
</tr>
|
529 |
</table>
|
530 |
</div>
|
531 |
+
|
532 |
+
<div id="tabs-advanced">
|
533 |
+
<table class="form-table">
|
534 |
+
<tr>
|
535 |
+
<th><?php _e('Enable on-the-fly compression', 'hyper-cache'); ?></th>
|
536 |
+
<td>
|
537 |
+
<?php $controls->checkbox('gzip_on_the_fly'); ?>
|
538 |
+
|
539 |
+
<p class="description">
|
540 |
+
<?php _e('Enable on the fly compression for non cached pages.', 'hyper-cache'); ?>
|
541 |
+
</p>
|
542 |
+
</td>
|
543 |
+
</tr>
|
544 |
+
<tr>
|
545 |
+
<tr>
|
546 |
+
<th><?php _e('When a post receives a comment', 'hyper-cache'); ?></th>
|
547 |
+
<td>
|
548 |
+
<?php $controls->checkbox('clean_archives_on_comment'); ?> clean archives (categories, tags, ..., but not the home)
|
549 |
+
<br>
|
550 |
+
<?php $controls->checkbox('clean_home_on_comment'); ?> clean the home
|
551 |
+
<p class="description">
|
552 |
+
|
553 |
+
</p>
|
554 |
+
</td>
|
555 |
+
</tr>
|
556 |
+
<tr>
|
557 |
+
|
558 |
+
<th><?php _e('When the home is refreshed, refresh even the', 'hyper-cache'); ?></th>
|
559 |
+
<td>
|
560 |
+
<?php $controls->text('clean_last_posts', 5); ?> <?php _e('latest post', 'hyper-cache'); ?>
|
561 |
+
<p class="description">
|
562 |
+
<?php _e('The number of latest posts to invalidate when the home is invalidated.', 'hyper-cache'); ?>
|
563 |
+
</p>
|
564 |
+
</td>
|
565 |
+
</tr>
|
566 |
+
|
567 |
+
<tr>
|
568 |
+
<th><?php _e('Next autoclean will run in', 'hyper-cache'); ?></th>
|
569 |
+
<td>
|
570 |
+
<?php $controls->checkbox('autoclean', 'enable it'); ?>
|
571 |
+
|
572 |
+
(<?php _e('will run again in', 'hyper-cache'); ?> <?php echo (int)((wp_next_scheduled('hyper_cache_clean')-time())/60) ?> <?php _e('minutes', 'hyper-cache'); ?>)
|
573 |
+
<p class="description">
|
574 |
+
<?php _e('The autoclean process removes old files to save disk space.', 'hyper-cache'); ?>
|
575 |
+
<?php _e('If you enable the "serve expired pages to bots", you should disable the auto clean.', 'hyper-cache'); ?>
|
576 |
+
</p>
|
577 |
+
</td>
|
578 |
+
</tr>
|
579 |
+
|
580 |
+
<tr>
|
581 |
+
<th><?php _e('Cache folder', 'hyper-cache'); ?></th>
|
582 |
+
<td>
|
583 |
+
<?php if (defined('HYPER_CACHE_FOLDER')) { ?>
|
584 |
+
<?php _e('A custom cache folder is deinfed in wp-config.php', 'hyper-cache'); ?>: <code><?php echo esc_html(HYPER_CACHE_FOLDER)?></code>
|
585 |
+
<?php } else { ?>
|
586 |
+
<?php _e('A custom cache folder can be defined in wp-config.php', 'hyper-cache'); ?>
|
587 |
+
<code>define('HYPER_CACHE_FOLDER', '/path/to/cache/folder');</code>
|
588 |
+
<?php } ?>
|
589 |
+
</td>
|
590 |
+
</tr>
|
591 |
+
</table>
|
592 |
+
</div>
|
593 |
|
594 |
<div id="tabs-mobile">
|
595 |
<table class="form-table">
|
plugin.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: Hyper Cache
|
5 |
Plugin URI: https://www.satollo.net/plugins/hyper-cache
|
6 |
Description: A easy to configure and efficient cache to increase the speed of your blog.
|
7 |
-
Version: 3.3.
|
8 |
Author: Stefano Lissa
|
9 |
Author URI: https://www.satollo.net
|
10 |
Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
|
@@ -37,9 +37,10 @@ class HyperCache {
|
|
37 |
add_action('wp_update_comment_count', array($this, 'hook_wp_update_comment_count'), 1);
|
38 |
add_action('bbp_new_reply', array($this, 'hook_bbp_new_reply'));
|
39 |
add_action('bbp_new_topic', array($this, 'hook_bbp_new_topic'));
|
|
|
40 |
|
41 |
add_action('hyper_cache_clean', array($this, 'hook_hyper_cache_clean'));
|
42 |
-
|
43 |
add_action('autoptimize_action_cachepurged', array($this, 'hook_autoptimize_action_cachepurged'));
|
44 |
|
45 |
if (!is_admin()) {
|
@@ -121,9 +122,10 @@ class HyperCache {
|
|
121 |
file_put_contents(WP_CONTENT_DIR . '/advanced-cache.php', '');
|
122 |
wp_clear_scheduled_hook('hyper_cache_clean');
|
123 |
}
|
124 |
-
|
125 |
function hook_admin_enqueue_scripts() {
|
126 |
-
if (!isset($_GET['page']) || strpos($_GET['page'], 'hyper-cache/') !== 0)
|
|
|
127 |
wp_enqueue_style('hyper_cache', 'https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css');
|
128 |
wp_enqueue_script('jquery-ui-tabs');
|
129 |
}
|
@@ -183,9 +185,8 @@ class HyperCache {
|
|
183 |
$dir = $this->get_folder() . '/' . substr($forum_url, strpos($forum_url, '://') + 3) . '/';
|
184 |
$this->remove_dir($dir);
|
185 |
}
|
186 |
-
|
187 |
-
function hook_autoptimize_action_cachepurged()
|
188 |
-
{
|
189 |
$this->clean();
|
190 |
}
|
191 |
|
@@ -204,6 +205,7 @@ class HyperCache {
|
|
204 |
}
|
205 |
|
206 |
function hook_save_post($post_id) {
|
|
|
207 |
}
|
208 |
|
209 |
/**
|
@@ -213,9 +215,8 @@ class HyperCache {
|
|
213 |
function hook_edit_post($post_id) {
|
214 |
$this->clean_post($post_id, isset($this->options['clean_archives_on_post_edit']), isset($this->options['clean_home_on_post_edit']));
|
215 |
}
|
216 |
-
|
217 |
-
function clean()
|
218 |
-
{
|
219 |
$folder = $this->get_folder();
|
220 |
$this->remove_dir($folder);
|
221 |
do_action('hyper_cache_purged');
|
@@ -246,7 +247,7 @@ class HyperCache {
|
|
246 |
$folder = trailingslashit($this->get_folder());
|
247 |
$dir = $folder . $this->post_folder($post_id);
|
248 |
$this->remove_dir($dir);
|
249 |
-
|
250 |
do_action('hyper_cache_flush', $post_id, get_permalink($post_id));
|
251 |
|
252 |
if ($this->options['clean_last_posts'] != 0) {
|
@@ -333,8 +334,28 @@ class HyperCache {
|
|
333 |
return $theme->template;
|
334 |
}
|
335 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
336 |
function hook_template_redirect() {
|
337 |
-
global $cache_stop, $hyper_cache_stop, $
|
338 |
|
339 |
if ($this->ob_started) {
|
340 |
return;
|
@@ -342,8 +363,8 @@ class HyperCache {
|
|
342 |
|
343 |
$home_root = parse_url(get_option('home'), PHP_URL_PATH);
|
344 |
|
345 |
-
if ($cache_stop || $hyper_cache_stop
|
346 |
-
|
347 |
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
348 |
$cache_stop = true;
|
349 |
} else if (!empty($_SERVER['QUERY_STRING'])) {
|
@@ -382,12 +403,12 @@ class HyperCache {
|
|
382 |
if (isset($this->options['reject_404'])) {
|
383 |
$cache_stop = true;
|
384 |
} else {
|
385 |
-
$file = $this->get_folder() . '/' .
|
386 |
|
387 |
if (file_exists($file) && ($this->options['max_age'] == 0 || filemtime($file) > time() - $this->options['max_age'] * 3600)) {
|
388 |
header('Content-Type: text/html;charset=UTF-8');
|
389 |
// For some reason it seems more performant than readfile...
|
390 |
-
header('X-Hyper-Cache: hit,404');
|
391 |
echo file_get_contents($file);
|
392 |
die();
|
393 |
}
|
@@ -534,22 +555,6 @@ class HyperCache {
|
|
534 |
|
535 |
}
|
536 |
|
537 |
-
/*
|
538 |
-
function hyper_cache_remove_protocol($buffer) {
|
539 |
-
|
540 |
-
$buffer = str_ireplace('"http://', '"//', $buffer);
|
541 |
-
$buffer = str_ireplace('\'http://', '\'//', $buffer);
|
542 |
-
return $buffer;
|
543 |
-
|
544 |
-
$parts = parse_url(get_home_url());
|
545 |
-
$buffer = str_ireplace('http://' . $parts['host'], '//' . $parts['host'], $buffer);
|
546 |
-
$buffer = str_ireplace('https://' . $parts['host'], '//' . $parts['host'], $buffer);
|
547 |
-
return $buffer;
|
548 |
-
|
549 |
-
}
|
550 |
-
|
551 |
-
*/
|
552 |
-
|
553 |
function hyper_cache_cdn_callback($matches) {
|
554 |
//error_log($matches[1]);
|
555 |
$parts = parse_url($matches[2]);
|
@@ -600,8 +605,11 @@ function hyper_cache_callback($buffer) {
|
|
600 |
|
601 |
$uri = hyper_cache_sanitize_uri($_SERVER['REQUEST_URI']);
|
602 |
$host = hyper_cache_sanitize_host($_SERVER['HTTP_HOST']);
|
603 |
-
|
604 |
-
|
|
|
|
|
|
|
605 |
if ($hyper_cache_is_mobile) {
|
606 |
// Bypass (should no need since there is that control on advanced-cache.php)
|
607 |
if ($options['mobile'] == 2) {
|
@@ -617,7 +625,7 @@ function hyper_cache_callback($buffer) {
|
|
617 |
}
|
618 |
|
619 |
if (is_404()) {
|
620 |
-
$lc_file =
|
621 |
} else {
|
622 |
$lc_file = $lc_dir . '/index' . $hyper_cache_group . '.html';
|
623 |
|
@@ -628,40 +636,40 @@ function hyper_cache_callback($buffer) {
|
|
628 |
|
629 |
if (!isset($options['reject_comment_authors']) && is_singular() && !is_feed() && !is_user_logged_in()) {
|
630 |
if (function_exists('is_amp_endpoint') && !is_amp_endpoint()) {
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
}
|
656 |
}
|
657 |
|
658 |
-
@file_put_contents($lc_file, $buffer . '<!-- hyper cache ' . date('Y-m-d
|
659 |
|
660 |
// Saves the gzipped version
|
661 |
if (isset($options['gzip'])) {
|
662 |
$gzf = gzopen($lc_file . '.gz', 'wb9');
|
663 |
if ($gzf !== false) {
|
664 |
-
gzwrite($gzf, $buffer . '<!-- hyper cache gzip ' . date('Y-m-d
|
665 |
gzclose($gzf);
|
666 |
}
|
667 |
}
|
@@ -670,23 +678,23 @@ function hyper_cache_callback($buffer) {
|
|
670 |
|
671 |
if (!function_exists('hyper_cache_sanitize_uri')) {
|
672 |
|
673 |
-
function hyper_cache_sanitize_uri($uri) {
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
|
|
|
|
679 |
}
|
680 |
-
return $uri;
|
681 |
-
}
|
682 |
|
683 |
}
|
684 |
|
685 |
if (!function_exists('hyper_cache_sanitize_host')) {
|
686 |
|
687 |
-
function hyper_cache_sanitize_host($host) {
|
688 |
-
|
689 |
-
|
690 |
-
}
|
691 |
|
692 |
}
|
4 |
Plugin Name: Hyper Cache
|
5 |
Plugin URI: https://www.satollo.net/plugins/hyper-cache
|
6 |
Description: A easy to configure and efficient cache to increase the speed of your blog.
|
7 |
+
Version: 3.3.8
|
8 |
Author: Stefano Lissa
|
9 |
Author URI: https://www.satollo.net
|
10 |
Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
|
37 |
add_action('wp_update_comment_count', array($this, 'hook_wp_update_comment_count'), 1);
|
38 |
add_action('bbp_new_reply', array($this, 'hook_bbp_new_reply'));
|
39 |
add_action('bbp_new_topic', array($this, 'hook_bbp_new_topic'));
|
40 |
+
add_action('wp', array($this, 'hook_wp'));
|
41 |
|
42 |
add_action('hyper_cache_clean', array($this, 'hook_hyper_cache_clean'));
|
43 |
+
|
44 |
add_action('autoptimize_action_cachepurged', array($this, 'hook_autoptimize_action_cachepurged'));
|
45 |
|
46 |
if (!is_admin()) {
|
122 |
file_put_contents(WP_CONTENT_DIR . '/advanced-cache.php', '');
|
123 |
wp_clear_scheduled_hook('hyper_cache_clean');
|
124 |
}
|
125 |
+
|
126 |
function hook_admin_enqueue_scripts() {
|
127 |
+
if (!isset($_GET['page']) || strpos($_GET['page'], 'hyper-cache/') !== 0)
|
128 |
+
return;
|
129 |
wp_enqueue_style('hyper_cache', 'https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css');
|
130 |
wp_enqueue_script('jquery-ui-tabs');
|
131 |
}
|
185 |
$dir = $this->get_folder() . '/' . substr($forum_url, strpos($forum_url, '://') + 3) . '/';
|
186 |
$this->remove_dir($dir);
|
187 |
}
|
188 |
+
|
189 |
+
function hook_autoptimize_action_cachepurged() {
|
|
|
190 |
$this->clean();
|
191 |
}
|
192 |
|
205 |
}
|
206 |
|
207 |
function hook_save_post($post_id) {
|
208 |
+
|
209 |
}
|
210 |
|
211 |
/**
|
215 |
function hook_edit_post($post_id) {
|
216 |
$this->clean_post($post_id, isset($this->options['clean_archives_on_post_edit']), isset($this->options['clean_home_on_post_edit']));
|
217 |
}
|
218 |
+
|
219 |
+
function clean() {
|
|
|
220 |
$folder = $this->get_folder();
|
221 |
$this->remove_dir($folder);
|
222 |
do_action('hyper_cache_purged');
|
247 |
$folder = trailingslashit($this->get_folder());
|
248 |
$dir = $folder . $this->post_folder($post_id);
|
249 |
$this->remove_dir($dir);
|
250 |
+
|
251 |
do_action('hyper_cache_flush', $post_id, get_permalink($post_id));
|
252 |
|
253 |
if ($this->options['clean_last_posts'] != 0) {
|
334 |
return $theme->template;
|
335 |
}
|
336 |
|
337 |
+
function hook_wp() {
|
338 |
+
global $cache_stop, $hyper_cache_stop, $hyper_cache_group, $hc_host;
|
339 |
+
if (is_404()) {
|
340 |
+
|
341 |
+
if (isset($this->options['reject_404'])) {
|
342 |
+
$cache_stop = true;
|
343 |
+
} else {
|
344 |
+
$file = $this->get_folder() . '/' . $hc_host . '/404' . $hyper_cache_group . '.html';
|
345 |
+
|
346 |
+
if (file_exists($file) && ($this->options['max_age'] == 0 || filemtime($file) > time() - $this->options['max_age'] * 3600)) {
|
347 |
+
header('Content-Type: text/html;charset=UTF-8');
|
348 |
+
// For some reason it seems more performant than readfile...
|
349 |
+
header('X-Hyper-Cache: hit,404,wp');
|
350 |
+
echo file_get_contents($file);
|
351 |
+
die();
|
352 |
+
}
|
353 |
+
}
|
354 |
+
}
|
355 |
+
}
|
356 |
+
|
357 |
function hook_template_redirect() {
|
358 |
+
global $cache_stop, $hyper_cache_stop, $hyper_cache_group, $hc_host;
|
359 |
|
360 |
if ($this->ob_started) {
|
361 |
return;
|
363 |
|
364 |
$home_root = parse_url(get_option('home'), PHP_URL_PATH);
|
365 |
|
366 |
+
if ($cache_stop || $hyper_cache_stop) {
|
367 |
+
|
368 |
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
369 |
$cache_stop = true;
|
370 |
} else if (!empty($_SERVER['QUERY_STRING'])) {
|
403 |
if (isset($this->options['reject_404'])) {
|
404 |
$cache_stop = true;
|
405 |
} else {
|
406 |
+
$file = $this->get_folder() . '/' . $hc_host . '/404' . $hyper_cache_group . '.html';
|
407 |
|
408 |
if (file_exists($file) && ($this->options['max_age'] == 0 || filemtime($file) > time() - $this->options['max_age'] * 3600)) {
|
409 |
header('Content-Type: text/html;charset=UTF-8');
|
410 |
// For some reason it seems more performant than readfile...
|
411 |
+
header('X-Hyper-Cache: hit,404,template_redirect');
|
412 |
echo file_get_contents($file);
|
413 |
die();
|
414 |
}
|
555 |
|
556 |
}
|
557 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
558 |
function hyper_cache_cdn_callback($matches) {
|
559 |
//error_log($matches[1]);
|
560 |
$parts = parse_url($matches[2]);
|
605 |
|
606 |
$uri = hyper_cache_sanitize_uri($_SERVER['REQUEST_URI']);
|
607 |
$host = hyper_cache_sanitize_host($_SERVER['HTTP_HOST']);
|
608 |
+
if (is_404()) {
|
609 |
+
$lc_dir = HyperCache::$instance->get_folder() . '/' . $host;
|
610 |
+
} else {
|
611 |
+
$lc_dir = HyperCache::$instance->get_folder() . '/' . $host . $uri;
|
612 |
+
}
|
613 |
if ($hyper_cache_is_mobile) {
|
614 |
// Bypass (should no need since there is that control on advanced-cache.php)
|
615 |
if ($options['mobile'] == 2) {
|
625 |
}
|
626 |
|
627 |
if (is_404()) {
|
628 |
+
$lc_file = $lc_dir . '/404' . $hyper_cache_group . '.html';
|
629 |
} else {
|
630 |
$lc_file = $lc_dir . '/index' . $hyper_cache_group . '.html';
|
631 |
|
636 |
|
637 |
if (!isset($options['reject_comment_authors']) && is_singular() && !is_feed() && !is_user_logged_in()) {
|
638 |
if (function_exists('is_amp_endpoint') && !is_amp_endpoint()) {
|
639 |
+
$script = '<script>';
|
640 |
+
$script .= 'function lc_get_cookie(name) {';
|
641 |
+
$script .= 'var c = document.cookie;';
|
642 |
+
$script .= 'if (c.indexOf(name) != -1) {';
|
643 |
+
$script .= 'var x = c.indexOf(name)+name.length+1;';
|
644 |
+
$script .= 'var y = c.indexOf(";",x);';
|
645 |
+
$script .= 'if (y < 0) y = c.length;';
|
646 |
+
$script .= 'return decodeURIComponent(c.substring(x,y));';
|
647 |
+
$script .= '} else return "";}';
|
648 |
+
$script .= 'if ((d = document.getElementById("commentform")) != null) { e = d.elements;';
|
649 |
+
$script .= 'var z = lc_get_cookie("comment_author_email_' . COOKIEHASH . '");';
|
650 |
+
$script .= 'if (z != "") e["email"].value = z;';
|
651 |
+
$script .= 'z = lc_get_cookie("comment_author_' . COOKIEHASH . '");';
|
652 |
+
$script .= 'if (z != "") e["author"].value = z.replace(/\+/g, " ");';
|
653 |
+
$script .= 'z = lc_get_cookie("comment_author_url_' . COOKIEHASH . '");';
|
654 |
+
$script .= 'if (z != "") e["url"].value = z;';
|
655 |
+
$script .= '}';
|
656 |
+
$script .= '</script>';
|
657 |
+
$x = strrpos($buffer, '</body>');
|
658 |
+
if ($x) {
|
659 |
+
$buffer = substr($buffer, 0, $x) . $script . '</body></html>';
|
660 |
+
} else {
|
661 |
+
$buffer .= $script;
|
662 |
+
}
|
663 |
}
|
664 |
}
|
665 |
|
666 |
+
@file_put_contents($lc_file, $buffer . '<!-- hyper cache ' . date('Y-m-d H:i:s') . ' -->');
|
667 |
|
668 |
// Saves the gzipped version
|
669 |
if (isset($options['gzip'])) {
|
670 |
$gzf = gzopen($lc_file . '.gz', 'wb9');
|
671 |
if ($gzf !== false) {
|
672 |
+
gzwrite($gzf, $buffer . '<!-- hyper cache gzip ' . date('Y-m-d H:i:s') . ' -->');
|
673 |
gzclose($gzf);
|
674 |
}
|
675 |
}
|
678 |
|
679 |
if (!function_exists('hyper_cache_sanitize_uri')) {
|
680 |
|
681 |
+
function hyper_cache_sanitize_uri($uri) {
|
682 |
+
$uri = preg_replace('|[^a-zA-Z0-9/\-_]+|', '_', $uri);
|
683 |
+
$uri = preg_replace('|/+|', '/', $uri);
|
684 |
+
$uri = rtrim($uri, '/');
|
685 |
+
if (empty($uri) || $uri[0] != '/') {
|
686 |
+
$uri = '/' . $uri;
|
687 |
+
}
|
688 |
+
return $uri;
|
689 |
}
|
|
|
|
|
690 |
|
691 |
}
|
692 |
|
693 |
if (!function_exists('hyper_cache_sanitize_host')) {
|
694 |
|
695 |
+
function hyper_cache_sanitize_host($host) {
|
696 |
+
$host = preg_replace('|[^a-zA-Z0-9\.]+|', '', $host);
|
697 |
+
return strtolower($host);
|
698 |
+
}
|
699 |
|
700 |
}
|
readme.txt
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
=== Hyper Cache ===
|
2 |
Tags: cache,performance,staticizer,apache,htaccess,tuning,speed,bandwidth,optimization,tidy,gzip,compression,server load,boost
|
3 |
Requires at least: 3.9
|
4 |
-
Tested up to:
|
5 |
-
Stable tag: 3.3.
|
6 |
Donate link: https://www.satollo.net/donations
|
7 |
Contributors: satollo
|
8 |
|
@@ -66,6 +66,11 @@ the [Hyper Cache official forum](https://www.satollo.net/forums/forum/hyper-cach
|
|
66 |
|
67 |
== Changelog ==
|
68 |
|
|
|
|
|
|
|
|
|
|
|
69 |
= 3.3.7 =
|
70 |
|
71 |
* Fixed http link on options panel
|
1 |
=== Hyper Cache ===
|
2 |
Tags: cache,performance,staticizer,apache,htaccess,tuning,speed,bandwidth,optimization,tidy,gzip,compression,server load,boost
|
3 |
Requires at least: 3.9
|
4 |
+
Tested up to: 5.2
|
5 |
+
Stable tag: 3.3.8
|
6 |
Donate link: https://www.satollo.net/donations
|
7 |
Contributors: satollo
|
8 |
|
66 |
|
67 |
== Changelog ==
|
68 |
|
69 |
+
= 3.3.8 =
|
70 |
+
|
71 |
+
* Small improvement on 404 caching
|
72 |
+
* General compatibility check with latest WP
|
73 |
+
|
74 |
= 3.3.7 =
|
75 |
|
76 |
* Fixed http link on options panel
|