Post content handler for Fragment Cache

2.0.0 2014-10-30 13:43 UTC

This package is auto-updated.

Last update: 2023-09-26 12:10:10 UTC


Post Content Handler for Fragment Cache is an extension of the awesome WordPress plugin "Fragment Cache" by Andrey "Rarst" Savchenko.

Fragment Cache allows partial and async caching of heavy front-end elements. It currently supports caching navigation menus, widgets, and galleries.

Post Content Handler for Fragment Cache (PCHFC) adds an additional "cache handler" to allow caching of post content in singular views.

PCHFC was realized for a client site, where a premium theme forced to build page content using an insane number of nested shortcodes, ending up in a quite slow page loading.

Full-page caching was not an option, because in that site there are (outside of post content) a lot of user-specific stuff.

Thanks to Fragment Cache I was able to code this handler that allowed me to successfully cache post content, without affecting the rest of the page.

Of course, posts having simple, text only content should not be cached, otherwise page loading time increase instead of decrease: for this reason the plugin add a metabox in the post edit screen where is possible to enable or disable the post content caching.

Post edit screen metabox

A client requirement was that metabox should be only visible to users with specific capability. So I added a setting page (accessible from Settings -> Fragment Cache) where is possible to change the capability required to view the metabox and enable or disable post content fragment caching.

Settings for Post Content Handler for Fragment Cache

As you can see in the screenshot, another option is available: the possibility to choose for which post types the post content caching should be available. When custom post types are registered, they are also visible and selectable in that setting, but unselected by default.

###Standalone Mode###

As said, PCHFC is just an extension of Fragment Cache, however, even if that plugin is not installed and activated in WordPress, thanks to Fragment Cache Composer support, a copy of the plugin is "embedded" in Post Content Handler folder and so PCHFC can work in "standalone" mode: i.e. you can install PCHFC without having to install Fragment Cache.

When Fragment Cache is installed, it enables the 3 core handlers:

  • Menu
  • Widget
  • Gallery

and they can only disabled via code. See docs for more info.

When in standalone mode, PCHFC adds an additional setting that allow to enable / disable the 3 core handlers.

Settings for Post Content Core Handlers



PCHFC is a Composer package and can be installed in plugin directory via:

composer create-project gmazzap/fc-post-content-handler --no-dev


PCHFC is in development and largely experimental. It has been tested in a very limited amount of conditions and sites. I suggest to test it in a staging / development environment before using it in production.


Post Content Handler for Fragment Cache is released under GPLv2+, just like Fragment Cache. Please refers to Fragment Cache readme for license of 3rd parties code required by Fragment Cache.