Version Description
- Added support for srcset in WP 4.4
- Improved encoding (utf8)
Download this release
Release Info
Developer | keycdn |
Plugin | Cache Enabler – WordPress Cache |
Version | 1.0.8 |
Comparing to | |
See all releases |
Code changes from version 1.0.7 to 1.0.8
- cache-enabler.php +2 -2
- inc/cache_enabler_disk.class.php +52 -4
- readme.txt +21 -7
cache-enabler.php
CHANGED
@@ -6,12 +6,12 @@ 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.
|
10 |
*/
|
11 |
|
12 |
/*
|
13 |
-
Copyright (C) 2011-2015 Sergej Müller
|
14 |
Copyright (C) 2015 KeyCDN
|
|
|
15 |
|
16 |
This program is free software; you can redistribute it and/or modify
|
17 |
it under the terms of the GNU General Public License as published by
|
6 |
Author: KeyCDN
|
7 |
Author URI: https://www.keycdn.com
|
8 |
License: GPLv2 or later
|
9 |
+
Version: 1.0.8
|
10 |
*/
|
11 |
|
12 |
/*
|
|
|
13 |
Copyright (C) 2015 KeyCDN
|
14 |
+
Copyright (C) 2011-2015 Sergej Müller
|
15 |
|
16 |
This program is free software; you can redistribute it and/or modify
|
17 |
it under the terms of the GNU General Public License as published by
|
inc/cache_enabler_disk.class.php
CHANGED
@@ -205,6 +205,7 @@ final class Cache_Enabler_Disk {
|
|
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 |
readfile( self::_file_webp_gzip() );
|
209 |
exit;
|
210 |
}
|
@@ -212,6 +213,7 @@ final class Cache_Enabler_Disk {
|
|
212 |
// check encoding and deliver gzip file if support
|
213 |
if ( $http_accept_encoding && ( strpos($http_accept_encoding, 'gzip') !== false ) ) {
|
214 |
header('Content-Encoding: gzip');
|
|
|
215 |
readfile( self::_file_gzip() );
|
216 |
exit;
|
217 |
}
|
@@ -498,7 +500,7 @@ final class Cache_Enabler_Disk {
|
|
498 |
* convert to webp
|
499 |
*
|
500 |
* @since 1.0.1
|
501 |
-
* @change 1.0.
|
502 |
*
|
503 |
* @return string converted HTML file
|
504 |
*/
|
@@ -506,7 +508,7 @@ final class Cache_Enabler_Disk {
|
|
506 |
private static function _convert_webp($data) {
|
507 |
|
508 |
$dom = new DOMDocument();
|
509 |
-
|
510 |
|
511 |
$imgs = $dom->getElementsByTagName("img");
|
512 |
|
@@ -516,6 +518,10 @@ final class Cache_Enabler_Disk {
|
|
516 |
$src_webp = self::_convert_webp_src($src);
|
517 |
if ($src != $src_webp) {
|
518 |
$img->setAttribute('src' , $src_webp);
|
|
|
|
|
|
|
|
|
519 |
}
|
520 |
|
521 |
}
|
@@ -538,12 +544,12 @@ final class Cache_Enabler_Disk {
|
|
538 |
|
539 |
|
540 |
/**
|
541 |
-
* convert to webp source
|
542 |
*
|
543 |
* @since 1.0.1
|
544 |
* @change 1.0.6
|
545 |
*
|
546 |
-
* @return string converted webp source
|
547 |
*/
|
548 |
|
549 |
private static function _convert_webp_src($src) {
|
@@ -568,4 +574,46 @@ final class Cache_Enabler_Disk {
|
|
568 |
return $src;
|
569 |
}
|
570 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
571 |
}
|
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 |
}
|
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 |
}
|
500 |
* convert to webp
|
501 |
*
|
502 |
* @since 1.0.1
|
503 |
+
* @change 1.0.8
|
504 |
*
|
505 |
* @return string converted HTML file
|
506 |
*/
|
508 |
private static function _convert_webp($data) {
|
509 |
|
510 |
$dom = new DOMDocument();
|
511 |
+
@$dom->loadHTML(mb_convert_encoding($data, 'HTML-ENTITIES', 'UTF-8'));
|
512 |
|
513 |
$imgs = $dom->getElementsByTagName("img");
|
514 |
|
518 |
$src_webp = self::_convert_webp_src($src);
|
519 |
if ($src != $src_webp) {
|
520 |
$img->setAttribute('src' , $src_webp);
|
521 |
+
|
522 |
+
// convert srcset attributes
|
523 |
+
$srcset = $img->getAttribute('srcset');
|
524 |
+
$img->setAttribute('srcset' , self::_convert_webp_srcset($srcset));
|
525 |
}
|
526 |
|
527 |
}
|
544 |
|
545 |
|
546 |
/**
|
547 |
+
* convert src to webp source
|
548 |
*
|
549 |
* @since 1.0.1
|
550 |
* @change 1.0.6
|
551 |
*
|
552 |
+
* @return string converted src webp source
|
553 |
*/
|
554 |
|
555 |
private static function _convert_webp_src($src) {
|
574 |
return $src;
|
575 |
}
|
576 |
|
577 |
+
|
578 |
+
/**
|
579 |
+
* convert srcset to webp source
|
580 |
+
*
|
581 |
+
* @since 1.0.8
|
582 |
+
* @change 1.0.8
|
583 |
+
*
|
584 |
+
* @return string converted srcset webp source
|
585 |
+
*/
|
586 |
+
|
587 |
+
private static function _convert_webp_srcset($srcset) {
|
588 |
+
|
589 |
+
$sizes = explode(', ', $srcset);
|
590 |
+
|
591 |
+
for ($i=0; $i<count($sizes); $i++) {
|
592 |
+
|
593 |
+
if ( strpos($sizes[$i], 'wp-content') !== false ) {
|
594 |
+
|
595 |
+
$src_webp = str_replace('.jpg', '.webp', $sizes[$i]);
|
596 |
+
$src_webp = str_replace('.png', '.webp', $src_webp);
|
597 |
+
|
598 |
+
$sizeParts = explode(' ', $src_webp);
|
599 |
+
$parts = explode('/wp-content/uploads', $sizeParts[0]);
|
600 |
+
$relative_path = $parts[1];
|
601 |
+
|
602 |
+
$upload_path = wp_upload_dir();
|
603 |
+
$base_dir = $upload_path['basedir'];
|
604 |
+
|
605 |
+
// check if relative path is not empty and file exists
|
606 |
+
if ( !empty($relative_path) && file_exists($base_dir.$relative_path) ) {
|
607 |
+
$sizes[$i] = $src_webp;
|
608 |
+
}
|
609 |
+
|
610 |
+
}
|
611 |
+
|
612 |
+
}
|
613 |
+
|
614 |
+
$srcset = implode(', ', $sizes);
|
615 |
+
|
616 |
+
return $srcset;
|
617 |
+
}
|
618 |
+
|
619 |
}
|
readme.txt
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
=== Cache Enabler - WordPress
|
2 |
Contributors: keycdn
|
3 |
-
Tags: cache, caching, performance
|
4 |
Requires at least: 4.1
|
5 |
-
Tested up to: 4.
|
6 |
Stable tag: trunk
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -15,8 +15,8 @@ A lightweight caching plugin for WordPress that makes your website faster by gen
|
|
15 |
|
16 |
== Description ==
|
17 |
|
18 |
-
|
19 |
-
The Cache Enabler plugin creates static HTML files and stores them on the servers disk. The web server will deliver the static HTML file and avoids the resource intensive backend processes (core, plugins and database). This will improve the performance of your
|
20 |
|
21 |
|
22 |
= Features =
|
@@ -27,11 +27,21 @@ The Cache Enabler plugin creates static HTML files and stores them on the server
|
|
27 |
* WordPress multisite support
|
28 |
* Custom Post Type support
|
29 |
* Expiry Directive
|
|
|
30 |
* WebP Support (when combined with [Optimus](https://optimus.io/en/ "Optimus"))
|
31 |
* HTTP/2 Focused
|
32 |
|
33 |
> 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.
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
= Support =
|
36 |
Just [contact us](https://www.keycdn.com/contacts "Support Request") directly to get support on this plugin.
|
37 |
|
@@ -42,7 +52,7 @@ Just [contact us](https://www.keycdn.com/contacts "Support Request") directly to
|
|
42 |
|
43 |
|
44 |
= Website =
|
45 |
-
* [Cache Enabler Documentation](https://www.keycdn.com/support/wordpress-cache-enabler-plugin/ "Cache Enabler Documentation")
|
46 |
|
47 |
|
48 |
= Maintainer =
|
@@ -52,11 +62,15 @@ Just [contact us](https://www.keycdn.com/contacts "Support Request") directly to
|
|
52 |
|
53 |
|
54 |
= Credits =
|
55 |
-
This plugin is partially based on
|
56 |
|
57 |
|
58 |
== Changelog ==
|
59 |
|
|
|
|
|
|
|
|
|
60 |
= 1.0.7 =
|
61 |
* Added cache behavior option for new posts
|
62 |
* Improved metainformation of the signature
|
1 |
+
=== Cache Enabler - WordPress Cache ===
|
2 |
Contributors: keycdn
|
3 |
+
Tags: cache, caching, wordpress cache, performance, gzip, webp, http2
|
4 |
Requires at least: 4.1
|
5 |
+
Tested up to: 4.4
|
6 |
Stable tag: trunk
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
15 |
|
16 |
== Description ==
|
17 |
|
18 |
+
= WordPress Cache Engine =
|
19 |
+
The Cache Enabler plugin creates static HTML files and stores them on the servers disk. The web server will deliver the static HTML file and avoids the resource intensive backend processes (core, plugins and database). This WordPress cache engine will improve the performance of your website.
|
20 |
|
21 |
|
22 |
= Features =
|
27 |
* WordPress multisite support
|
28 |
* Custom Post Type support
|
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? =
|
38 |
+
This plugin requires minimal setup time and allows you to easily take advantage of the benefits that come from using Wordpress caching.
|
39 |
+
|
40 |
+
The Wordpress Cache Enabler has the ability to create 2 cached files. One is plain HTML and the other version is gzipped (gzip level 9). These static files are then used to deliver content faster to your users directly via PHP without any database lookups or gzipping as the files are already pre-compressed. You can use our [advanced configuration snippets](https://www.keycdn.com/support/wordpress-cache-enabler-plugin/#advanced-configuration "WP cache config snippet") to even *bypass PHP* calls required to fetch the static HTML files.
|
41 |
+
|
42 |
+
When combined with Optimus, the Wordpress Cache Enabler allows you to easily deliver WebP images. The plugin will check your wp-content/uploads directory for any JPG or PNG images that have an equivalent WebP file. If there is, the URI of these image will be cached in a WebP static file by Cache Enabler. It is not required for all images to be converted to WebP when the "Create an additional cached version for WebP image support" option is enabled. This will not break any images that are not in WebP format. The plugin will deliver images that do have a WebP equivalent and will fall back to the JPG or PNG format for images that don't.
|
43 |
+
|
44 |
+
|
45 |
= Support =
|
46 |
Just [contact us](https://www.keycdn.com/contacts "Support Request") directly to get support on this plugin.
|
47 |
|
52 |
|
53 |
|
54 |
= Website =
|
55 |
+
* [WordPress Cache Enabler - Documentation](https://www.keycdn.com/support/wordpress-cache-enabler-plugin/ "WordPress Cache Enabler - Documentation")
|
56 |
|
57 |
|
58 |
= Maintainer =
|
62 |
|
63 |
|
64 |
= Credits =
|
65 |
+
This WordPress cache plugin is partially based on Cachify developed by [Sergej Müller](https://wordpress.org/plugins/cachify/ "Author Sergej Müller").
|
66 |
|
67 |
|
68 |
== Changelog ==
|
69 |
|
70 |
+
= 1.0.8 =
|
71 |
+
* Added support for srcset in WP 4.4
|
72 |
+
* Improved encoding (utf8)
|
73 |
+
|
74 |
= 1.0.7 =
|
75 |
* Added cache behavior option for new posts
|
76 |
* Improved metainformation of the signature
|