Cache Enabler – WordPress Cache - Version 1.0.9

Version Description

  • Option to disable pre-compression of cached pages if decoding fails
Download this release

Release Info

Developer keycdn
Plugin Icon 128x128 Cache Enabler – WordPress Cache
Version 1.0.9
Comparing to
See all releases

Code changes from version 1.0.8 to 1.0.9

cache-enabler.php CHANGED
@@ -6,7 +6,7 @@ Description: Simple and fast WordPress disk caching plugin.
6
  Author: KeyCDN
7
  Author URI: https://www.keycdn.com
8
  License: GPLv2 or later
9
- Version: 1.0.8
10
  */
11
 
12
  /*
6
  Author: KeyCDN
7
  Author URI: https://www.keycdn.com
8
  License: GPLv2 or later
9
+ Version: 1.0.9
10
  */
11
 
12
  /*
inc/cache_enabler.class.php CHANGED
@@ -464,7 +464,7 @@ final class Cache_Enabler {
464
  * get options
465
  *
466
  * @since 1.0.0
467
- * @change 1.0.7
468
  *
469
  * @return array options array
470
  */
@@ -477,6 +477,7 @@ final class Cache_Enabler {
477
  'expires' => 0,
478
  'new_post' => 0,
479
  'new_comment' => 0,
 
480
  'webp' => 0,
481
  'excl_ids' => '',
482
  'minify_html' => self::MINIFY_DISABLED,
@@ -1515,7 +1516,7 @@ final class Cache_Enabler {
1515
  * validate settings
1516
  *
1517
  * @since 1.0.0
1518
- * @change 1.0.7
1519
  *
1520
  * @param array $data array form data
1521
  * @return array array form data valid
@@ -1536,6 +1537,7 @@ final class Cache_Enabler {
1536
  'new_post' => (int)(!empty($data['new_post'])),
1537
  'new_comment' => (int)(!empty($data['new_comment'])),
1538
  'webp' => (int)(!empty($data['webp'])),
 
1539
  'excl_ids' => (string)sanitize_text_field(@$data['excl_ids']),
1540
  'minify_html' => (int)$data['minify_html']
1541
  );
@@ -1546,7 +1548,7 @@ final class Cache_Enabler {
1546
  * settings page
1547
  *
1548
  * @since 1.0.0
1549
- * @change 1.0.7
1550
  */
1551
 
1552
  public static function settings_page() { ?>
@@ -1598,6 +1600,13 @@ final class Cache_Enabler {
1598
 
1599
  <br />
1600
 
 
 
 
 
 
 
 
1601
  <label for="cache_webp">
1602
  <input type="checkbox" name="cache[webp]" id="cache_webp" value="1" <?php checked('1', $options['webp']); ?> />
1603
  <?php _e("Create an additional cached version for WebP image support. Convert your images to WebP with <a href=\"https://optimus.io/en/\" target=\"_blank\">Optimus</a>.", "cache") ?>
464
  * get options
465
  *
466
  * @since 1.0.0
467
+ * @change 1.0.9
468
  *
469
  * @return array options array
470
  */
477
  'expires' => 0,
478
  'new_post' => 0,
479
  'new_comment' => 0,
480
+ 'compress' => 1,
481
  'webp' => 0,
482
  'excl_ids' => '',
483
  'minify_html' => self::MINIFY_DISABLED,
1516
  * validate settings
1517
  *
1518
  * @since 1.0.0
1519
+ * @change 1.0.9
1520
  *
1521
  * @param array $data array form data
1522
  * @return array array form data valid
1537
  'new_post' => (int)(!empty($data['new_post'])),
1538
  'new_comment' => (int)(!empty($data['new_comment'])),
1539
  'webp' => (int)(!empty($data['webp'])),
1540
+ 'compress' => (int)(!empty($data['compress'])),
1541
  'excl_ids' => (string)sanitize_text_field(@$data['excl_ids']),
1542
  'minify_html' => (int)$data['minify_html']
1543
  );
1548
  * settings page
1549
  *
1550
  * @since 1.0.0
1551
+ * @change 1.0.9
1552
  */
1553
 
1554
  public static function settings_page() { ?>
1600
 
1601
  <br />
1602
 
1603
+ <label for="cache_compress">
1604
+ <input type="checkbox" name="cache[compress]" id="cache_compress" value="1" <?php checked('1', $options['compress']); ?> />
1605
+ <?php _e("Pre-compression of cached pages. Needs to be disabled if the decoding fails in the web browser.", "cache") ?>
1606
+ </label>
1607
+
1608
+ <br />
1609
+
1610
  <label for="cache_webp">
1611
  <input type="checkbox" name="cache[webp]" id="cache_webp" value="1" <?php checked('1', $options['webp']); ?> />
1612
  <?php _e("Create an additional cached version for WebP image support. Convert your images to WebP with <a href=\"https://optimus.io/en/\" target=\"_blank\">Optimus</a>.", "cache") ?>
inc/cache_enabler_disk.class.php CHANGED
@@ -156,7 +156,7 @@ final class Cache_Enabler_Disk {
156
  * clear home cache
157
  *
158
  * @since 1.0.7
159
- * @change 1.0.7
160
  */
161
 
162
  public static function clear_home() {
@@ -168,10 +168,10 @@ final class Cache_Enabler_Disk {
168
  DIRECTORY_SEPARATOR
169
  );
170
 
171
- unlink($path.self::FILE_HTML);
172
- unlink($path.self::FILE_GZIP);
173
- unlink($path.self::FILE_WEBP_HTML);
174
- unlink($path.self::FILE_WEBP_GZIP);
175
  }
176
 
177
 
@@ -179,7 +179,7 @@ final class Cache_Enabler_Disk {
179
  * get asset
180
  *
181
  * @since 1.0.0
182
- * @change 1.0.7
183
  */
184
 
185
  public static function get_asset() {
@@ -203,17 +203,20 @@ final class Cache_Enabler_Disk {
203
  }
204
 
205
  // check webp and deliver gzip webp file if support
206
- if ( $http_accept && ( strpos($http_accept, 'webp') !== false ) && is_readable( self::_file_webp_gzip() ) ) {
207
- header('Content-Encoding: gzip');
208
- //header('Content-Type: text/html; charset=UTF-8');
209
- readfile( self::_file_webp_gzip() );
210
- exit;
 
 
 
 
211
  }
212
 
213
  // check encoding and deliver gzip file if support
214
- if ( $http_accept_encoding && ( strpos($http_accept_encoding, 'gzip') !== false ) ) {
215
  header('Content-Encoding: gzip');
216
- //header('Content-Type: text/html; charset=UTF-8');
217
  readfile( self::_file_gzip() );
218
  exit;
219
  }
@@ -249,7 +252,7 @@ final class Cache_Enabler_Disk {
249
  * create files
250
  *
251
  * @since 1.0.0
252
- * @change 1.0.0
253
  *
254
  * @param string $data html content
255
  */
@@ -264,18 +267,26 @@ final class Cache_Enabler_Disk {
264
  // get base signature
265
  $cache_signature = self::_cache_signatur();
266
 
 
 
 
267
  // create files
268
  self::_create_file( self::_file_html(), $data.$cache_signature." (html) -->" );
269
- self::_create_file( self::_file_gzip(), gzencode($data.$cache_signature." (html gzip) -->", 9) );
270
 
271
- // cache enabler options
272
- $options = Cache_Enabler::$options;
 
 
273
 
274
  // create webp supported files
275
  if ($options['webp']) {
276
  $converted_data = self::_convert_webp($data);
277
  self::_create_file( self::_file_webp_html(), $converted_data.$cache_signature." (webp) -->" );
278
- self::_create_file( self::_file_webp_gzip(), gzencode($converted_data.$cache_signature." (webp gzip) -->", 9) );
 
 
 
 
279
  }
280
 
281
  }
156
  * clear home cache
157
  *
158
  * @since 1.0.7
159
+ * @change 1.0.9
160
  */
161
 
162
  public static function clear_home() {
168
  DIRECTORY_SEPARATOR
169
  );
170
 
171
+ @unlink($path.self::FILE_HTML);
172
+ @unlink($path.self::FILE_GZIP);
173
+ @unlink($path.self::FILE_WEBP_HTML);
174
+ @unlink($path.self::FILE_WEBP_GZIP);
175
  }
176
 
177
 
179
  * get asset
180
  *
181
  * @since 1.0.0
182
+ * @change 1.0.9
183
  */
184
 
185
  public static function get_asset() {
203
  }
204
 
205
  // check webp and deliver gzip webp file if support
206
+ if ( $http_accept && ( strpos($http_accept, 'webp') !== false ) ) {
207
+ if ( is_readable( self::_file_webp_gzip() ) ) {
208
+ header('Content-Encoding: gzip');
209
+ readfile( self::_file_webp_gzip() );
210
+ exit;
211
+ } else {
212
+ readfile( self::_file_webp_html() );
213
+ exit;
214
+ }
215
  }
216
 
217
  // check encoding and deliver gzip file if support
218
+ if ( $http_accept_encoding && ( strpos($http_accept_encoding, 'gzip') !== false ) && is_readable( self::_file_gzip() ) ) {
219
  header('Content-Encoding: gzip');
 
220
  readfile( self::_file_gzip() );
221
  exit;
222
  }
252
  * create files
253
  *
254
  * @since 1.0.0
255
+ * @change 1.0.9
256
  *
257
  * @param string $data html content
258
  */
267
  // get base signature
268
  $cache_signature = self::_cache_signatur();
269
 
270
+ // cache enabler options
271
+ $options = Cache_Enabler::$options;
272
+
273
  // create files
274
  self::_create_file( self::_file_html(), $data.$cache_signature." (html) -->" );
 
275
 
276
+ // create pre-compressed file
277
+ if ($options['compress']) {
278
+ self::_create_file( self::_file_gzip(), gzencode($data.$cache_signature." (html gzip) -->", 9) );
279
+ }
280
 
281
  // create webp supported files
282
  if ($options['webp']) {
283
  $converted_data = self::_convert_webp($data);
284
  self::_create_file( self::_file_webp_html(), $converted_data.$cache_signature." (webp) -->" );
285
+
286
+ // create pre-compressed file
287
+ if ($options['compress']) {
288
+ self::_create_file( self::_file_webp_gzip(), gzencode($converted_data.$cache_signature." (webp gzip) -->", 9) );
289
+ }
290
  }
291
 
292
  }
readme.txt CHANGED
@@ -29,9 +29,10 @@ The Cache Enabler plugin creates static HTML files and stores them on the server
29
  * Expiry Directive
30
  * Support of *304 Not Modified* if the page has not modified since last cached
31
  * WebP Support (when combined with [Optimus](https://optimus.io/en/ "Optimus"))
 
32
  * HTTP/2 Focused
33
 
34
- > Cache Enabler is the first WP plugin to allow you to serve WebP images without JavaScript. WebP is a new image format that provides lossless and lossy compression for images on the web. WebP lossless images are [26% smaller](https://developers.google.com/speed/webp/docs/webp_lossless_alpha_study#results "webp lossless alpha study") in size compared to PNGs.
35
 
36
 
37
  = How does the caching work? =
@@ -67,6 +68,9 @@ This WordPress cache plugin is partially based on Cachify developed by [Sergej M
67
 
68
  == Changelog ==
69
 
 
 
 
70
  = 1.0.8 =
71
  * Added support for srcset in WP 4.4
72
  * Improved encoding (utf8)
29
  * Expiry Directive
30
  * Support of *304 Not Modified* if the page has not modified since last cached
31
  * WebP Support (when combined with [Optimus](https://optimus.io/en/ "Optimus"))
32
+ * Supports responsive images via srcset since WP 4.4
33
  * HTTP/2 Focused
34
 
35
+ > Cache Enabler is the first WP plugin to allow you to serve WebP images without JavaScript and also fully supports srcset since WP 4.4. WebP is a new image format that provides lossless and lossy compression for images on the web. WebP lossless images are [26% smaller](https://developers.google.com/speed/webp/docs/webp_lossless_alpha_study#results "webp lossless alpha study") in size compared to PNGs.
36
 
37
 
38
  = How does the caching work? =
68
 
69
  == Changelog ==
70
 
71
+ = 1.0.9 =
72
+ * Option to disable pre-compression of cached pages if decoding fails
73
+
74
  = 1.0.8 =
75
  * Added support for srcset in WP 4.4
76
  * Improved encoding (utf8)