PluginProbe ʕ •ᴥ•ʔ
10Web Booster – Website speed optimization, Cache & Page Speed optimizer / trunk
10Web Booster – Website speed optimization, Cache & Page Speed optimizer vtrunk
2.33.0 2.30.5 2.30.7 2.30.9 2.31.10 2.31.8 2.32.11 2.32.21 2.32.3 2.32.4 2.32.7 2.6.31 2.6.40 2.6.42 2.6.7 2.7.37 2.7.44 2.7.47 2.8.18 2.8.19 2.8.32 2.8.34 2.8.35 2.9.23 2.9.24 2.9.25 2.9.27 v2.27.4 trunk 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.17 2.0.18 2.0.21 2.0.22 2.0.25 2.0.26 2.0.27 2.0.3 2.0.7 2.0.9 2.10.46 2.10.65 2.10.66 2.10.68 2.11.41 2.11.42 2.11.43 2.12.15 2.12.21 2.12.22 2.12.23 2.12.26 2.13.37 2.13.40 2.13.41 2.13.42 2.13.44 2.13.45 2.13.47 2.14.49 2.14.50 2.15.18 2.17.21 2.17.23 2.18.17 2.19.44 2.19.45 2.19.46 2.19.49 2.2.12 2.2.15 2.2.16 2.2.18 2.2.8 2.20.31 2.20.32 2.20.33 2.21.11 2.21.12 2.21.16 2.21.25 2.22.32 2.23.13 2.23.15 2.23.16 2.23.18 2.24.12 2.24.14 2.24.18 2.25.14 2.26.6 2.28.10 2.28.13 2.28.14 2.28.7 2.29.1 2.29.2 2.29.3 2.3.0 2.3.1 2.3.2 2.3.3 2.30.18
tenweb-speed-optimizer / config / default.php
tenweb-speed-optimizer / config Last commit date
default.php 2 years ago index.html 4 years ago
default.php
86 lines
1 <?php
2
3 // phpcs:ignoreFile
4 exit;
5
6 //Check everything exists before using it
7 if (!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
8 $_SERVER['HTTP_ACCEPT_ENCODING'] = '';
9 }
10
11 if (!isset($_SERVER['HTTP_USER_AGENT'])) {
12 $_SERVER['HTTP_USER_AGENT'] = '';
13 }
14 // Determine supported compression method
15 $gzip = strstr(sanitize_text_field($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip');
16 $deflate = strstr(sanitize_text_field($_SERVER['HTTP_ACCEPT_ENCODING']), 'deflate');
17 // Determine used compression method
18 $encoding = $gzip ? 'gzip' : ($deflate ? 'deflate' : 'none');
19
20 // Check for buggy versions of Internet Explorer
21 if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Opera') && preg_match('/^Mozilla\/4\.0 \(compatible; MSIE ([0-9]\.[0-9])/i', $_SERVER['HTTP_USER_AGENT'], $matches)) {
22 $version = floatval($matches[1]);
23
24 if ($version < 6) {
25 $encoding = 'none';
26 }
27
28 if ($version == 6 && !strstr($_SERVER['HTTP_USER_AGENT'], 'EV1')) {
29 $encoding = 'none';
30 }
31 }
32
33 //Some servers compress the output of PHP - Don't break in those cases
34 if (ini_get('output_handler') == 'ob_gzhandler' || ini_get('zlib.output_compression') == 1) {
35 $encoding = 'none';
36 }
37 $iscompressed = file_exists(__FILE__ . '.' . $encoding);
38
39 if ($encoding != 'none' && $iscompressed == false) {
40 $flag = ($encoding == 'gzip' ? FORCE_GZIP : FORCE_DEFLATE);
41 $code = file_get_contents(__FILE__ . '.none');
42 $contents = gzencode($code, 9, $flag);
43 } else {
44 //Get data
45 $contents = file_get_contents(__FILE__ . '.' . $encoding);
46 }
47 // first check if we have to send 304
48 // inspired by http://www.jonasjohn.de/snippets/php/caching.htm
49 $eTag = md5($contents);
50 $modTime = filemtime(__FILE__ . '.none');
51 $eTagMatch = (isset($_SERVER['HTTP_IF_NONE_MATCH']) && strpos($_SERVER['HTTP_IF_NONE_MATCH'], $eTag));
52 $modTimeMatch = (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) === $modTime);
53
54 if (($modTimeMatch) || ($eTagMatch)) {
55 header('HTTP/1.1 304 Not Modified');
56 header('Connection: close');
57 } else {
58 // send all sorts of headers
59 $expireTime = 60 * 60 * 24 * 355; // 1y max according to RFC
60
61 if ($encoding != 'none') {
62 header('Content-Encoding: ' . $encoding);
63 }
64 header('Vary: Accept-Encoding');
65 header('Content-Length: ' . strlen($contents));
66 header('Content-type: %%CONTENT%%; charset=utf-8');
67 header('Cache-Control: max-age=' . $expireTime . ', public, must-revalidate');
68 header('Cache-Control: max-age=' . $expireTime . ', public, immutable');
69 header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expireTime) . ' GMT');
70 header('ETag: ' . $eTag);
71 header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $modTime) . ' GMT');
72 // send output
73 echo wp_kses_post($contents);
74
75 //And write to filesystem cache if not done yet
76 if ($encoding != 'none' && $iscompressed == false) {
77 //Write the content we sent
78 file_put_contents(__FILE__ . '.' . $encoding, $contents);
79 //And write the new content
80 $flag = ($encoding == 'gzip' ? FORCE_DEFLATE : FORCE_GZIP);
81 $ext = ($encoding == 'gzip' ? 'deflate' : 'gzip');
82 $contents = gzencode($code, 9, $flag);
83 file_put_contents(__FILE__ . '.' . $ext, $contents);
84 }
85 }
86