Skip to content

fix(cli): honor -c cache_mode instead of always bypassing the cache (#2365) - #2366

Merged
ntohidi merged 2 commits into
developfrom
fix/2365-cli-cache-mode
Oct 14, 2026
Merged

ntohidi merged 2 commits into
developfrom
fix/2365-cli-cache-mode

Conversation

@ntohidi

@ntohidi ntohidi commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #2365. crwl ignored -c cache_mode=... and always bypassed the cache, for two reasons:

  1. --bypass-cache was a flag with default=True, so it always set CacheMode.BYPASS after -c and config files were applied.
  2. -c and YAML/JSON configs pass cache_mode as a string ("enabled"). CacheMode is a plain Enum, so the string never matched and the cache was never read or written.

--bypass-cache now defaults to False. CrawlerRunConfig already defaults to BYPASS, so plain crwl still skips the cache. CrawlerRunConfig now converts a string cache_mode to CacheMode, and an invalid value raises an error.

crwl crawl https://example.com -o all -c cache_mode=enabled   # cache_status: miss
crwl crawl https://example.com -o all -c cache_mode=enabled   # cache_status: hit
crwl crawl https://example.com -o all                          # cache_status: miss (bypass)

List of files changed and why

  • crawl4ai/cli.py: --bypass-cache defaults to False in crwl and crwl crawl.
  • crawl4ai/async_configs.py: convert a string cache_mode to CacheMode.
  • tests/cli/test_cli.py: default is still BYPASS; -c cache_mode=enabled gives ENABLED; -bc still forces BYPASS.

test_examples, test_missing_url and test_basic_crawl in tests/cli/test_cli.py already fail on develop; this PR does not change them.

…2365)

--bypass-cache was a flag with default=True, so it always forced
CacheMode.BYPASS after -c and config files were applied. Default it to
False; CrawlerRunConfig already defaults to BYPASS, so plain crwl still
skips the cache.

-c and YAML/JSON configs also pass cache_mode as a string, which never
matched the CacheMode enum, so CrawlerRunConfig now converts it.
CrawlerRunConfig now converts a string cache_mode to CacheMode and raises
ValueError on an unknown one, which the Docker API turned into a 500.
Check it in the untrusted gate so /crawl and /crawl/stream answer 400.

The playground template test compared the raw "bypass" string with the
loaded config; cache_mode is now a CacheMode, so compare enum values.
@ntohidi
ntohidi merged commit f475c3b into develop Oct 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant