I
I
Ivan Ivanov2018-04-28 11:14:40
1C-Bitrix
Ivan Ivanov, 2018-04-28 11:14:40

How to cache a block of code on a website (cms Bitrix)?

Hello. Please help me figure it out. I have never really worked with the Bitrix cache, but I need to do it. Installed Yandex reviews on the site. In the footer of the site. The problem is that Yandex review allows you to make no more than 100 requests per day. There is a get request through the Yandex API to get a list of reviews about the site. But each time you refresh the page, the request occurs on a new one. How to wrap the code so that it makes a request once. In theory, of course, you can use jquery cookies, but it seems to me that this is not a very elegant solution. In theory, is it possible to somehow do this using the Bitrix cache? Tell me where to dig? Thanks
Addendum:
Found the CPhpCache Class but I can't figure out how it works... how do I wrap the whole thing... my request get code

<?$url = "https://api.content.market.yandex.ru/v1/shop/302613/opinion.xml?sort=rank&count=1";
                           $headers = array(
                                 "Host: api.content.market.yandex.ru",
                                 "Accept: */*",
                                 "Authorization: 98c671b8-a96a-444a-8c53-660b4c63d4e2"
                              );
                              $ch = curl_init();
                              curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                              curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
                              curl_setopt($ch, CURLOPT_URL, $url);
                              curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                              $data = curl_exec($ch);
                              curl_close($ch);?>
                           
                        <?echo $data?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita, 2018-04-28
@ZZiliST

poke

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question