Bitrix: working with composite cache.
Битрикс: работа с композитным кешем.

All English-language materials have been translated fully automatically using the Google service

First, go to /bitrix/admin/composite.php?lang=en and open the Settings item. These settings will be enough:

Composite mode settings

Turn on logging

 define ("BX_COMPOSITE_DEBUG", true);
define ("LOG_FILENAME", $ _SERVER ["DOCUMENT_ROOT"]. "/ log.txt"); 

Dynamic content outside of a component, for example in a template


\Bitrix\Main\Page\Frame::getInstance()->finishDynamicWithID("dynamic-area", "Загрузка...");

Dynamic buffered content

$frame = new \Bitrix\Main\Page\FrameHelper("dynamic-area");
   //динамический контент

Dynamic area with browser cache. Load statics from the last hit

 $ frame = $this->createFrame('dynamic-area')->begin('');
$ frame-> setBrowserStorage (true);
// Content
$ frame-> end (); 

Dynamic area with spawn animation

 $ frame = $this->createFrame('dynamic-area')->begin('');
$ frame-> setAnimation (true);
 // Content
$ frame-> end (); 

Partial component caching. For example, when showing the current price

$frame = $this->createFrame('price-index', false)->begin()		
	echo $price;
	echo 'руб.';			

Disable Composite Caching


Removing Composite Cache via API

$staticHtmlCache = \Bitrix\Main\Data\StaticHtmlCache::getInstance();


Composite and Region Dependent Content

In the init.php file, override the method that generates the file name in the composite cache.

class CacheProvider extends Bitrix\Main\Data\StaticCacheProvider
public static function createKey()
	global $USER;
	$page_name = "page";
		$page_name .= "_region_".$_SESSION["CITY_ID"];

	return $page_name;
public function setUserPrivateKey(){}
public function isCacheable()
	return true;
public function getCachePrivateKey()
	return self::createKey();
public function onBeforeEndBufferContent(){}

In the city definition component (for example articul.geolocation.detect_ip / component.php ) write the cookie BITRIX_SM_PK

setcookie("BITRIX_SM_PK", 'page_region_'.$_SESSION["CITY_ID"], $cookie_life, "/", constant("COOKIE_DOMAIN"));

In the file /local/php_interface/composite_first_start_cookie_fix.php we write the cookie BITRIX_SM_PK so that the composite will also work out on the first visit (we include this file BEFORE header. php on composite pages):

Original solution here


Worth reading:


There are no comments yet, you can be the first to leave it

Leave a comment

The site uses a comment pre-moderation system, so your message will be published only after approval by the moderator

You are replying to a user's comment



Email me

Are you developing a new service, making improvements to the existing one and want to be better than your competitors? You have come to the right place. I offer you a comprehensive studio-level website development. From me you can order design, layout, programming, development of non-traditional functionality, implementation of communication between CMS, CRM and Data Analitics, as well as everything else related to sites, except for promotion.

Contact, I will always advise on all questions and help you find the most effective solution for your business. I am engaged in the creation of sites in Novosibirsk and in other regions of Russia, I also work with the CIS countries. You will be satisfied with our cooperation

An error occurred while sending, please try again after a while
Message sent successfully


+7(993) 007-18-96



Россия, г. Москва

By submitting the form, you automatically confirm that you have read and accept the Privacy Policy site

Contact with me
Send message
By submitting the form, you automatically confirm that you have read and accept Privacy policy of site
Sending successful!
Thank you for contacting :) I will contact you as soon as possible
Sending failed
An error occurred while sending the request. Please wait and try again after a while or call my phone number