I
I
IG512017-09-25 07:59:01
1C-Bitrix
IG51, 2017-09-25 07:59:01

How to automate Bitrix cache cleaning?

Good day. The bitrix/cache/ folder grows. First of all, I manually cleared the cache in the admin panel.
Further, as it is written in the documentation, I wrote the following lines in the /bitrix/php_interface/dbconn.php file:

umask(000);
@umask(~BX_DIR_PERMISSIONS);

Then I found that the bitrix/cache/css folder was not cleared, and the upload folder was also quite large. what are the suggestions? thank.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2017-09-25
@IG51

Alas, clearing the folder via cron is not a good idea. In fact, you are not dealing with a problem, but with a symptom.
Why does the cache folder grow?
1) You have a very large and complex website.
For example, with 10 thousand products in one category, if you try to cache each page, the size will be large. Suppose a page with 10 products takes 10KB of cache (in fact, everything depends on the layout and can reach a larger size), then the total cache of the catalog will be 10KB * 10,000 = ~100MB (account cache, actually about 90MB).
Now let's consider that there can be 2 types of display: a list or a tile. Accordingly, already 180MB. And if there are not 10 thousand goods, but 100? And if there is also a filter and its results can be cached? And we counted only the directory and a rather small cache size.
Solution: choose caching time and increase disk space
2) Caching time is incorrectly defined.
For example: your ttl cache costs 3 months. And even if no one has visited it for 3 months, it is still stored. For example, you have a very large cache (which is very bad), which takes up 500KB (and sometimes 1 MB), it turns out that this 1MB will be stored for a long time, even if it is not accessed.
Solution: choose the caching time (perhaps it is worth reducing somewhere) and the parameters of the components (perhaps something should not be cached)
3) The cache of own or Bitrix components is incorrectly configured.
For example, there is a very big fad in Bitrix with the menu cache - if you specify MENU_CACHE_VARS (it seems to be written this way, I wrote it from memory), then it will create a cache for each set of parameters. And then the menu cache starts to swell a lot and also be cached for a long time.
Solution: You need to check the caching settings in the components. It is possible to rewrite in your components or see on the basis of what it is formed
4) An error with the cache clearing mechanism.
For example, when the cache does not have time to be deleted, and accumulates. Thus, the same cache is duplicated in different components.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question