Page 1 of 1

Great directory /_cache

Posted: 23 Jan 2018, 10:40
by poldix
Hello, Karl.
I have a question about the  .../_cache directory which generates a lot of files, over 37,000
The catalog   .../content has only 2,500 files
Can you limit the number of files being generated, why there are so many of them? The server has a limit of 150,000 files, it worries me because the site is just being created.
Cleaning from the panel does not change anything.
Regards

Re: Great directory /_cache

Posted: 23 Jan 2018, 11:11
by mjau-mjau
poldix wrote:Hello, Karl.
I have a question about the  .../_cache directory which generates a lot of files, over 37,000
The catalog   .../content has only 2,500 files
Let me explain a bit how this works: 2500 image files? Depending on screen size, mobile/desktop, gallery layout, retina etc, EACH image in your gallery may require 5-6 different image sizes rendered and cached. 2500 files x 6 sizes = 15,000 cache files already. In addition, X3 creates SYMLINKS to point to each cached image resize, as this is often faster. By rough calculation, you could double 15,000 x 2 = 30,000 files ... All which are actively used by X3.

To be honest, I have never heard about this being a problem with modern hosting. If you want to run a MODERN responsive gallery website like X3 on your own server, then you should accept the requirements also. How do you think Facebook, Instagram and Google store their images? They also have to create a range of different sizes for EACH image, and store them on server.

Furthermore, if you rename folders or change folder structure, your "stale" cache files will not immediately get deleted. A cached image doesn't know by itself that it is orphaned. Eventually, after approximately 1 month, if an image has not been requested, it will get purged from the cache ... But this means your cache may also include a lot of files that are outdated, but waiting to expire and get deleted.

Of course, the cache also includes PAGE cache for ALL your pages (html and json).

The answer is therefore no, we can't limit the cache files, because they are there for good reason. You delete your cache, and images will load slowly because they have to be re-processed on server. If we don't cache images at all, everything will be slower. There is no logical reason why a large amount of relatively small files on server should be a problem anyway.
poldix wrote:The server has a limit of 150,000 files, it worries me because the site is just being created.
What host is this? Never heard of a file amount limit before. Unfortunately, many hosting companies are over-selling their cheap services, and sometimes you simply can't expect much from a $3 service (I'm not saying yours is). We have worked hard to make X3 perform respectably also on slow/cheap hosting, amongst other things by the use of extensive caching.
poldix wrote:Cleaning from the panel does not change anything.
This only clears PAGE cache. It would not be logical to create an "empty image cache" function ... What's it for? In your case, you would want to use it to remove files which X3 uses, and the cache would rebuild anyway.

You can delete content of the image cache folders by FTP if you like, but I don't really see the point. It might help remove some cached images which belong to orphan/renamed paths, but these files will eventually remove themselves when not requested.

Re: Great directory /_cache

Posted: 23 Jan 2018, 17:52
by poldix
Thank you Karl for explaining the whole mechanism to me. Now I know that the only limitation of my site can only be poor hosting.
Regards   :slight_smile: