Changeset 3789168
- Timestamp:
- 11/07/2026 08:10:59 AM (less than one hour ago)
- Location:
- cache-shark/trunk
- Files:
-
- 3 added
- 5 edited
-
cache-shark.php (modified) (2 diffs)
-
readme.txt (modified) (6 diffs)
-
src/Admin.php (modified) (1 diff)
-
src/HtmlMask.php (added)
-
src/LazyLoad.php (added)
-
src/Optimizer.php (added)
-
src/PageCache.php (modified) (1 diff)
-
src/Settings.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cache-shark/trunk/cache-shark.php
r3785734 r3789168 2 2 /** 3 3 * Plugin Name: Cache Shark 4 * Description: Make your site fast with free, no-nonsense page caching. Cache Shark saves a static copy of each public page and serves it before WordPress, your theme and your plugins even load. It clears only the pages that changed when you publish or update content, warms the cache in the background from your sitemap, cleans up expired files and adds GZIP and browser-caching rules on Apache and LiteSpeed. Safe by default, with nothing to configure.5 * Version: 0. 1.04 * Description: Free, open-source page caching for WordPress. 5 * Version: 0.2.0 6 6 * Requires at least: 6.9 7 7 * Requires PHP: 7.4 … … 15 15 defined( 'ABSPATH' ) || exit; 16 16 17 define( 'CACHE_SHARK_VERSION', '0. 1.0' );17 define( 'CACHE_SHARK_VERSION', '0.2.0' ); 18 18 define( 'CACHE_SHARK_FILE', __FILE__ ); 19 19 define( 'CACHE_SHARK_DIR', plugin_dir_path( __FILE__ ) ); -
cache-shark/trunk/readme.txt
r3785734 r3789168 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 0. 1.07 Stable tag: 0.2.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 22 22 * **GZIP compression and browser caching** rules for Apache and LiteSpeed servers. 23 23 * **Expired page cleanup** keeps the cache folder from growing forever. 24 * **Lazy loading** for images and embedded videos or maps, so offscreen media loads only when a visitor scrolls near it. Off by default; the first images on each page are never delayed. 24 25 25 26 **Safe by default** … … 29 30 **Not included yet** 30 31 31 CSS and JavaScript minification, delayed JavaScript, lazy loading,critical CSS, CDN and database cleanup are planned for later releases. Multisite network activation is not supported yet.32 CSS and JavaScript minification, delayed JavaScript, critical CSS, CDN and database cleanup are planned for later releases. Multisite network activation is not supported yet. 32 33 33 34 **Privacy** … … 69 70 Preloading uses WP-Cron, which only runs when someone visits your site. On quiet sites, or if `DISABLE_WP_CRON` is set, add a server cron job that requests `wp-cron.php` every few minutes. 70 71 72 = Lazy loading changed how my page looks. = 73 74 Open Settings > Cache Shark and either untick lazy loading, raise "Skip the first images", or list the image's class name or file name under "Never lazy-load these". Clear the cache afterwards. 75 71 76 = What happens when I deactivate or delete the plugin? = 72 77 … … 79 84 == Changelog == 80 85 86 = 0.2.0 = 87 * New: optional lazy loading for images and iframes (off by default). Skips the first images on each page, images that already have a loading attribute, tracking pixels and anything in your exclude list. 88 81 89 = 0.1.0 = 82 90 * First release: page caching, automatic purging, sitemap preloading, expired page cleanup, GZIP and browser caching rules for Apache and LiteSpeed, settings page. … … 84 92 == Upgrade Notice == 85 93 94 = 0.2.0 = 95 Adds optional lazy loading. Nothing changes until you turn it on. 96 86 97 = 0.1.0 = 87 98 First release. -
cache-shark/trunk/src/Admin.php
r3785734 r3789168 199 199 </tr> 200 200 <tr> 201 <th scope="row"><?php esc_html_e( 'Lazy loading', 'cache-shark' ); ?></th> 202 <td> 203 <label><input type="checkbox" name="<?php echo esc_attr( $name ); ?>[lazy_images]" value="1" <?php checked( 1, (int) $o['lazy_images'] ); ?>> <?php esc_html_e( 'Lazy-load images', 'cache-shark' ); ?></label><br> 204 <label><input type="checkbox" name="<?php echo esc_attr( $name ); ?>[lazy_iframes]" value="1" <?php checked( 1, (int) $o['lazy_iframes'] ); ?>> <?php esc_html_e( 'Lazy-load iframes (embedded videos, maps)', 'cache-shark' ); ?></label> 205 <p class="description"><?php esc_html_e( 'Offscreen images and embeds load only when the visitor scrolls near them. WordPress already does this for images in post content; this also covers images from your theme and widgets. Applied to cached pages only, never to logged-in users.', 'cache-shark' ); ?></p> 206 </td> 207 </tr> 208 <tr> 209 <th scope="row"><label for="vc-skip"><?php esc_html_e( 'Skip the first images', 'cache-shark' ); ?></label></th> 210 <td> 211 <input id="vc-skip" type="number" min="0" max="20" class="small-text" name="<?php echo esc_attr( $name ); ?>[lazy_skip_first]" value="<?php echo esc_attr( (string) (int) $o['lazy_skip_first'] ); ?>"> 212 <p class="description"><?php esc_html_e( 'Images at the top of the page must show immediately. The first images on each page (default 2) are never lazy-loaded.', 'cache-shark' ); ?></p> 213 </td> 214 </tr> 215 <tr> 216 <th scope="row"><label for="vc-lazy-exclude"><?php esc_html_e( 'Never lazy-load these', 'cache-shark' ); ?></label></th> 217 <td> 218 <textarea id="vc-lazy-exclude" rows="4" class="large-text code" name="<?php echo esc_attr( $name ); ?>[lazy_exclude]"><?php echo esc_textarea( implode( "\n", (array) $o['lazy_exclude'] ) ); ?></textarea> 219 <p class="description"><?php esc_html_e( 'One per line. Any image or iframe whose HTML contains this text is skipped, for example a class name such as hero-image or a file name such as logo.png.', 'cache-shark' ); ?></p> 220 </td> 221 </tr> 222 <tr> 201 223 <th scope="row"><label for="vc-urls"><?php esc_html_e( 'Never cache these URLs', 'cache-shark' ); ?></label></th> 202 224 <td> -
cache-shark/trunk/src/PageCache.php
r3785734 r3789168 66 66 $status = (int) http_response_code(); 67 67 if ( '' !== $target && self::should_store( (string) $buffer, $status, headers_list() ) && ! ( defined( 'DONOTCACHEPAGE' ) && DONOTCACHEPAGE ) ) { 68 // Optimise only pages that are being cached. The visitor who triggers the 69 // cache write gets exactly the page every later visitor will get. 70 $out = Optimizer::run( (string) $buffer ); 68 71 CacheStore::write_file( 69 72 $target, 70 $ buffer. "\n<!-- Cached by Cache Shark on " . gmdate( 'Y-m-d H:i:s' ) . " UTC -->\n"73 $out . "\n<!-- Cached by Cache Shark on " . gmdate( 'Y-m-d H:i:s' ) . " UTC -->\n" 71 74 ); 75 return $out; 72 76 } 73 77 } catch ( \Throwable $e ) { -
cache-shark/trunk/src/Settings.php
r3785734 r3789168 15 15 'separate_mobile' => 0, 16 16 'preload' => 1, 17 'lazy_images' => 0, 18 'lazy_iframes' => 0, 19 'lazy_skip_first' => 2, 20 'lazy_exclude' => array(), 17 21 'exclude_urls' => array(), 18 22 'exclude_cookies' => array(), … … 51 55 'separate_mobile' => empty( $input['separate_mobile'] ) ? 0 : 1, 52 56 'preload' => empty( $input['preload'] ) ? 0 : 1, 57 'lazy_images' => empty( $input['lazy_images'] ) ? 0 : 1, 58 'lazy_iframes' => empty( $input['lazy_iframes'] ) ? 0 : 1, 59 'lazy_skip_first' => max( 0, min( 20, (int) ( $input['lazy_skip_first'] ?? 2 ) ) ), 60 'lazy_exclude' => $lines( $input['lazy_exclude'] ?? '' ), 53 61 'exclude_urls' => $urls, 54 62 'exclude_cookies' => $lines( $input['exclude_cookies'] ?? '' ),
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)