Official Crawl4AI Cloud: a hosted web scraping, extraction, and search API for AI agents. Free API key, 1,000 credits a month, no card. Fully open source: this repo is the Apache-2.0 crawler that powers it, and you can self-host it.
Python aiai-agentscrawl4ai-cloudcrawlerdata-extractionllmmarkdownmcpopen-sourceplaywrightpythonragscraperweb-crawlerweb-crawlingweb-scraping
fix(cli): honor -c cache_mode instead of always bypassing the cache (#2365)
ntohidi018053b152ed
diff --git a/crawl4ai/async_configs.py b/crawl4ai/async_configs.pyindex ad51cb17..fbea1e3f 100644--- a/crawl4ai/async_configs.py+++ b/crawl4ai/async_configs.py@@ -1942,7 +1942,8 @@ class CrawlerRunConfig():self.fetch_ssl_certificate = fetch_ssl_certificate# Caching Parameters- self.cache_mode = cache_mode+ # Accept "enabled" etc. from CLI -c and YAML/JSON config files+ self.cache_mode = CacheMode(cache_mode.lower()) if isinstance(cache_mode, str) else cache_modeself.session_id = session_idself.bypass_cache = bypass_cacheself.disable_cache = disable_cachediff --git a/crawl4ai/cli.py b/crawl4ai/cli.pyindex f82864a1..ecf333c2 100644--- a/crawl4ai/cli.py+++ b/crawl4ai/cli.py@@ -1023,7 +1023,7 @@ def cdp_cmd(user_data_dir: Optional[str], port: int, browser_type: str, headless@click.option("--crawler", "-c", type=str, callback=parse_key_values, help="Crawler parameters as key1=value1,key2=value2")@click.option("--output", "-o", type=click.Choice(["all", "json", "markdown", "md", "markdown-fit", "md-fit"]), default="all", help="json = extracted data only (needs -j or -e). Use 'all' (default) for the full crawl result.")@click.option("--output-file", "-O", type=click.Path(), help="Output file path (default: stdout)")[email protected]("--bypass-cache", "-bc", is_flag=True, default=True, help="Bypass cache when crawling")[email protected]("--bypass-cache", "-bc", is_flag=True, default=False, help="Bypass cache when crawling (the default unless -c cache_mode=... is set)")@click.option("--question", "-q", help="Ask a question about the crawled content")@click.option("--verbose", "-v", is_flag=True)@click.option("--profile", "-p", help="Use a specific browser profile (by name)")@@ -1587,7 +1587,7 @@ def shrink_cmd(profile_name: str, level: str, dry_run: bool):@click.option("--browser", "-b", type=str, callback=parse_key_values, help="Browser parameters as key1=value1,key2=value2")@click.option("--crawler", "-c", type=str, callback=parse_key_values, help="Crawler parameters as key1=value1,key2=value2")@click.option("--output", "-o", type=click.Choice(["all", "json", "markdown", "md", "markdown-fit", "md-fit"]), default="all", help="json = extracted data only (needs -j or -e). Use 'all' (default) for the full crawl result.")[email protected]("--bypass-cache", is_flag=True, default=True, help="Bypass cache when crawling")[email protected]("--bypass-cache", is_flag=True, default=False, help="Bypass cache when crawling (the default unless -c cache_mode=... is set)")@click.option("--question", "-q", help="Ask a question about the crawled content")@click.option("--verbose", "-v", is_flag=True)@click.option("--profile", "-p", help="Use a specific browser profile (by name)")diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.pyindex 1cf4b166..67770cbd 100644--- a/tests/cli/test_cli.py+++ b/tests/cli/test_cli.py@@ -268,5 +268,23 @@ def test_json_output_with_question_is_allowed(runner):run.assert_called() # no early error+def _crawler_cfg(runner, *args):+ with patch("crawl4ai.cli.anyio.run") as run:+ runner.invoke(cli, ["crawl", "https://example.com", "-o", "md", *args])+ return run.call_args.args[3]+++def test_cache_bypassed_by_default(runner):+ from crawl4ai import CacheMode+ assert _crawler_cfg(runner).cache_mode == CacheMode.BYPASS+++def test_crawler_param_cache_mode_is_honored(runner):+ # #2365: -c cache_mode=enabled was overridden and kept as a plain string+ from crawl4ai import CacheMode+ assert _crawler_cfg(runner, "-c", "cache_mode=enabled").cache_mode == CacheMode.ENABLED+ assert _crawler_cfg(runner, "-c", "cache_mode=enabled", "-bc").cache_mode == CacheMode.BYPASS++if __name__ == '__main__':pytest.main(['-v', '-s', '--tb=native', __file__])