Repository navigation
Please explain caching behaviour #784
Replies: 2 comments
|
Hi @BigNerd Crawl4ai employs a cache to store crawling results, and you can manage its usage through configuration options like bypassing it for specific URLs. Let's clarify the cache's behavior based on your questions: Entry Criteria: By default, if caching is enabled (which is the default Eviction Criteria and Maximum Size: Based on the provided codebase, crawl4ai does not implement explicit eviction criteria or a maximum size for the cache. The cache database, managed by One very important thing to mention is that the caching mechanism has two layers. We store data in a database and in the file system, especially for large content like HTML markdown. We create a hash for this content and store the hash code in the database. Then, we use the hash code as the name of the file and store it on a disk in the home directory of Crawl4ai. We always retrieve from there. This way, the database does not bloat and grow larger due to such large files. Cache-Control Headers: I'm happy you shared this point with us. This has been the backlog, and I will bring it up very soon. It's a good thing to consider, and I really like the idea. We added an option similar to how we handle the robot.txt and other items. Right now, the caching behavior solely depends on the cache mode you set in your crawler1 config and whether a matching entry exists in the local cache database. I will definitely prioritize this. Thanks again. Controlling Cache Usage: You can control cache usage through the
To manage cache size, you would need to implement manual cache clearing or size monitoring and control mechanisms, as the library does not provide built-in features for cache eviction or size limits. You can use methods like Future Plan |
|
Thank you for the quick and thorough response. This answers my questions and helps me to use your fantastic solution appropriately. As I am using your docker image running as a service, I will send all requests with CacheMode.BYPASS to avoid stale responses and infinite cache growth. I am looking forward to a redesigned cache mode. |
Uh oh!
There was an error while loading. Please reload this page.
As it seems, crawl4ai uses a cache and there are configuration options to control usage of the cache, e.g. by-pass the cache for a requested url. However, it is not clear from the documentation, as far as I can see, what the entry and eviction criteria and the maximum size of the cache are. Will every crawling result be cached (if cache is not by-passed)? Or will crawl4ai respect cache control headers from the source web sites, in order to only cache what is marked as cacheable and as long as it is permitted to cache according to HTTP cache control headers? Also, is there a maximum size applied to the cache and how can it be controlled or will the cache grow infinitely until the storage resources of the underlying machine are used up, leading to errors finally?
All reactions