Introducing content caching

This page serves to give you an overview about the new content caching functionality of Ceres and IO. The caching of content data of the online store prevents a recalculating of pages upon each new page view and therefore improves the performance of the online store. Data which has already been loaded or genertated once remains in the cache and can be invoked much faster when it is accessed again.

Preliminary information about content caching

Content caching is only available from Ceres and IO versions 2.12 onwards. Purchase the current versions of the plugins on the plentymarkets marketplace or update the plugins in the Plugins » Plugin overview.

Information about caching and invalidation

  • The cached data is retained for 7 days unless invalidated.
  • All online store pages are cached in IO with the exception of user-dependent data, which is loaded via REST. The following pages are not written into the cache:
    • Shopping cart
    • Checkout
    • MyAccount
    • Login and registration
    • Order confirmation
    • Wish list
    • Search
  • At this point in time, pages that feature query components in the URL cannot be cached, e.g. a URL such as "/category?page=3" is not written into the cache.
  • The cache can only be invalidated every 5 minutes.
  • The entire cache is invalidated through the following actions:
    • Saving and publishing a plugin set
    • Changing the settings of a plugin and saving the new settings
    • Linking layout containers in the CMS » Container links menu
  • The cache for individual variation pages is invalidated when changes are made to the item settings of the variation. The invalidation of variation pages is dependent on the refreshing of the Elasticsearch index, meaning that the aforementioned invalidation cycle of 5 minutes does not apply; the Elasticsearch index is refreshed every 10 to 15 minutes.

How to cache additional pages

If you, as a plugin developer, want to provide additional routes in your theme or plugin and want these to be written into the cache, you need to implement the following code snippet into your controller:

...
use Plenty\Modules\ContentCache\Contracts\ContentCacheRepositoryContract;

// ...

/** @var ContentCacheRepositoryContract $cacheRepository */
$cacheRepository = pluginApp(ContentCacheRepositoryContract::class);
$cacheRepository->enableCacheForResponse();

...
  

By integrating this code, you ensure that the additional routes are written into the cache. You can see how the code is implemented in the LayoutController of IO, located in the IO/src/Controllers/LayoutController.php file.

It is furthermore possible to link variation IDs to the respective cache entry, so that the cache is invalidated upon any changes to the variations. By implementing the following code snippet, the loaded variation IDs are transmitted to the caching module when item data is loaded:

...
use Plenty\Modules\ContentCache\Contracts\ContentCacheRepositoryContract;

// ...

/** @var ContentCacheRepositoryContract $contentCacheRepo */
$contentCacheRepo = pluginApp(ContentCacheRepositoryContract::class);
$contentCacheRepo->linkVariationsToResponse($variationIds); // $variationIds = [1,2,3];

...
  

In this case, the page is automatically invalidated whenever changes are being made to the variations with the IDs 1, 2 or 3.

Is this article helpful?

 

Thank you for your Feedback

you can close this field now!