Answer the question
In order to leave comments, you need to log in
How to force Bitrix not to cache certain parts of the code in the template?
Hello connoisseurs!
Who faced such game as caching in Bitrix? The essence of the question is that it is necessary to exclude a section of code from caching (a device definition condition). I use this library device.js , only it with a probability of 99% correctly detects devices. In my opinion! The essence of the question is that through ajax I write the device type to the session. Next, in the component template, I set the condition
if ($device == "mobile") {
$content = "content-mobile";
} else {
$content = "content-desktop";
}
Answer the question
In order to leave comments, you need to log in
Forgive me, of course, but the game in this case is what you offer. Not a single framework supports "not caching a certain area inside the cached one" (if you find a refutation - we will be happy to talk and consider how this algorithm can be used).
Actually, Bitrix has 2 mechanisms for solving your case:
1) Remove caching of the result (html) and make data caching.
In my opinion, not the best option, since rendering also requires resources that are already expensive
2) Define an additional caching key.
In StartResulCache, you can add your own keys to parameter 2, and in this case you will have the key of the user's device (mobile / desktop), after which 2 caches will be stored: for mobile and for desktop clients.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question