Plugin Directory

Changeset 3789168


Ignore:
Timestamp:
11/07/2026 08:10:59 AM (less than one hour ago)
Author:
mdraabiul
Message:

Release 0.2.0 - lazy loading

Location:
cache-shark/trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • cache-shark/trunk/cache-shark.php

    r3785734 r3789168  
    22/**
    33 * 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.0
     4 * Description:       Free, open-source page caching for WordPress.
     5 * Version:           0.2.0
    66 * Requires at least: 6.9
    77 * Requires PHP:      7.4
    … …  
    1515defined( 'ABSPATH' ) || exit;
    1616
    17 define( 'CACHE_SHARK_VERSION', '0.1.0' );
     17define( 'CACHE_SHARK_VERSION', '0.2.0' );
    1818define( 'CACHE_SHARK_FILE', __FILE__ );
    1919define( 'CACHE_SHARK_DIR', plugin_dir_path( __FILE__ ) );
  • cache-shark/trunk/readme.txt

    r3785734 r3789168  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 0.1.0
     7Stable tag: 0.2.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    2222* **GZIP compression and browser caching** rules for Apache and LiteSpeed servers.
    2323* **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.
    2425
    2526**Safe by default**
    … …  
    2930**Not included yet**
    3031
    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.
     32CSS and JavaScript minification, delayed JavaScript, critical CSS, CDN and database cleanup are planned for later releases. Multisite network activation is not supported yet.
    3233
    3334**Privacy**
    … …  
    6970Preloading 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.
    7071
     72= Lazy loading changed how my page looks. =
     73
     74Open 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
    7176= What happens when I deactivate or delete the plugin? =
    7277
    … …  
    7984== Changelog ==
    8085
     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
    8189= 0.1.0 =
    8290* First release: page caching, automatic purging, sitemap preloading, expired page cleanup, GZIP and browser caching rules for Apache and LiteSpeed, settings page.
    … …  
    8492== Upgrade Notice ==
    8593
     94= 0.2.0 =
     95Adds optional lazy loading. Nothing changes until you turn it on.
     96
    8697= 0.1.0 =
    8798First release.
  • cache-shark/trunk/src/Admin.php

    r3785734 r3789168  
    199199                                        </tr>
    200200                                        <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>
    201223                                                <th scope="row"><label for="vc-urls"><?php esc_html_e( 'Never cache these URLs', 'cache-shark' ); ?></label></th>
    202224                                                <td>
  • cache-shark/trunk/src/PageCache.php

    r3785734 r3789168  
    6666                        $status = (int) http_response_code();
    6767                        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 );
    6871                                CacheStore::write_file(
    6972                                        $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"
    7174                                );
     75                                return $out;
    7276                        }
    7377                } catch ( \Throwable $e ) {
  • cache-shark/trunk/src/Settings.php

    r3785734 r3789168  
    1515                        'separate_mobile' => 0,
    1616                        'preload'         => 1,
     17                        'lazy_images'     => 0,
     18                        'lazy_iframes'    => 0,
     19                        'lazy_skip_first' => 2,
     20                        'lazy_exclude'    => array(),
    1721                        'exclude_urls'    => array(),
    1822                        'exclude_cookies' => array(),
    … …  
    5155                        'separate_mobile' => empty( $input['separate_mobile'] ) ? 0 : 1,
    5256                        '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'] ?? '' ),
    5361                        'exclude_urls'    => $urls,
    5462                        'exclude_cookies' => $lines( $input['exclude_cookies'] ?? '' ),
Note: See TracChangeset for help on using the changeset viewer.