2017 © Pedro Peláez
 

wordpress-plugin fragment-cache

WordPress plugin for partial and async caching of heavy front-end elements.

image

rarst/fragment-cache

WordPress plugin for partial and async caching of heavy front-end elements.

  • Thursday, October 12, 2017
  • by Rarst
  • Repository
  • 14 Watchers
  • 104 Stars
  • 1,769 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 9 Forks
  • 1 Open issues
  • 6 Versions
  • 6 % Grown

The README.md

Fragment Cache

Scrutinizer Code Quality, (*1)

Fragment Cache is a WordPress plugin for partial and async caching of heavy front-end elements. It currently supports caching navigation menus, widgets, and galleries., (*2)

Caching is built on top of transients API (with enhancements provided by TLC Transients library), provides soft expiration and transparent object cache support., (*3)

Installation

Download plugin archive from releases section., (*4)

Or install in plugin directory via Composer:, (*5)

composer create-project rarst/fragment-cache --no-dev

Frequently Asked Questions

Why fragments don't recognize logged in users / current page?

Fragment Cache implements soft expiration - when fragments expire, they are regenerated asynchronously and do not take time in front end page load. The side effect is that it is impossible to preserve context precisely and in generic way., (*6)

Fragments that must be aware of users or other context information should be excluded from caching or handled by custom implementation, that properly handles that specific context., (*7)

How to disable caching?

Disable handler

Caching for the fragment type can be disabled by manipulating main plugin object:, (*8)

global $fragment_cache;

// completely remove handler, only use before init
unset( $fragment_cache['widget'] );

// or disable handler, use after init
$fragment_cache['widget']->disable();

Skip individual fragments

Caching for individual fragments can be disabled by using fc_skip_cache hook., (*9)

add_filter( 'fc_skip_cache', function ( $skip, $type, $name, $args, $salt ) {

    // Widget by class.
    if ( 'widget' === $type && is_a( $args['callback'][0], 'WP_Widget_Meta' ) ) {
        return true;
    }

    // Menu by theme location.
    if ( 'menu' === $type && isset( $args['theme_location'] ) && 'header' === $args['theme_location'] ) {
        return true;
    }

    // Menu by name.
    if ( 'menu' === $type && isset( $args['menu'] ) ) {

        if ( 'Menu with login' === $args['menu'] ) {
            return true;
        }

        if ( is_a( $args['menu'], 'WP_Term' ) && 'Menu with login' === $args['menu']->name ) {
            return true;
        }
    }

    // Gallery by ID of post.
    if ( 'gallery' === $type && 123 === $args['post_id'] ) {
        return true;
    }

    return $skip;
}, 10, 5 );

License Info

Fragment Cache own code is licensed under GPLv2+ and it makes use of code from:, (*10)

  • Composer (MIT)
  • Pimple (MIT)
  • TLC Transients (GPLv2+)

The Versions

12/10 2017

dev-master

9999999-dev https://github.com/Rarst/fragment-cache

WordPress plugin for partial and async caching of heavy front-end elements.

  Sources   Download

GPL-2.0+

The Requires

 

wordpress cache performance

11/12 2016

1.3.1

1.3.1.0 https://github.com/Rarst/fragment-cache

WordPress plugin for partial and async caching of heavy front-end elements.

  Sources   Download

GPL-2.0+

The Requires

 

wordpress cache performance

14/05 2016

1.3

1.3.0.0 https://github.com/Rarst/fragment-cache

WordPress plugin for partial and async caching of heavy front-end elements.

  Sources   Download

GPL-2.0+

The Requires

 

wordpress cache performance

29/06 2014

1.2

1.2.0.0 https://github.com/Rarst/fragment-cache

WordPress plugin for partial and async caching of heavy front-end elements.

  Sources   Download

GPL-2.0+

The Requires

 

wordpress cache performance

15/06 2013

1.1

1.1.0.0 https://bitbucket.org/Rarst/fragment-cache

WordPress plugin for partial and async caching of heavy front-end elements.

  Sources   Download

GPL-2.0+

The Requires

 

wordpress cache performance

08/06 2013

1.0

1.0.0.0 https://bitbucket.org/Rarst/fragment-cache

WordPress plugin for partial and async caching of heavy front-end elements.

  Sources   Download

GPL-2.0+

The Requires

 

wordpress cache performance