Overview
The cron recrawl endpoint triggers automatic recrawls of all sites that are due for updates. This is an internal endpoint designed to be called by scheduled tasks (AWS Lambda, GitHub Actions, cron jobs, etc.) to maintain up-to-datellms.txt files for enrolled sites.
This endpoint runs recrawls in the background and returns immediately. It does not wait for crawls to complete.
Endpoint
Authentication
This endpoint requires authentication via theX-Cron-Secret header:
string
required
Secret token configured in the backend’s
CRON_SECRET environment variable. This prevents unauthorized triggering of recrawls.Request
No request body is required. Authentication is handled entirely through the header.Example Request
Response
Success Response (200)
string
Always
"triggered" when the recrawl background task is successfully queued.string
Human-readable confirmation message.
Error Response (401)
Returned when the cron secret is missing, invalid, or doesn’t match the configured value.How It Works
1. Site Selection
The recrawl process:- Queries the
crawl_sitestable for sites wherenext_crawl_at <= NOW() - Retrieves site configuration (
max_pages,desc_length,recrawl_interval_minutes) - Processes each site sequentially
2. Change Detection
For each site, the system:- Checks sentinel URL (typically
sitemap.xml) for changes - Compares hash of new content with stored
latest_llms_hash - Skips crawl if content hasn’t changed (optimization)
- Full recrawl if changes detected or sentinel unavailable
3. Scheduling
After each check:- Content unchanged: Updates
next_crawl_atbased onrecrawl_interval_minutes - Content changed: Regenerates
llms.txt, uploads to R2, updates database - Adaptive scheduling: Adjusts interval based on change frequency (future feature)
Background Task
The recrawl logic is implemented in/backend/main.py:37-43 as a FastAPI background task:
/backend/recrawl.py.
Scheduling Examples
AWS Lambda + EventBridge
Lambda Function (lambda_handler.py):
GitHub Actions
Vercel Cron
vercel.json:Traditional Cron
Configuration
Environment Variables
Recrawl Intervals
When users enable auto-update via the WebSocket endpoint, they can specify:- Default: 10080 minutes (7 days)
- Common values:
- 360 minutes (6 hours)
- 1440 minutes (1 day)
- 10080 minutes (7 days)
Monitoring
Check logs to monitor recrawl status:Database Schema
The endpoint relies on thecrawl_sites table structure:
next_crawl_at: Determines if site is due for recrawllatest_llms_hash: Used for change detectionsentinel_url: Quick check endpoint (usually sitemap.xml)
Error Codes
Performance Considerations
- Background Processing: Returns immediately, doesn’t block
- Sequential Crawling: Processes sites one at a time to manage resources
- Smart Skipping: Avoids full crawls when content unchanged
- Timeout Handling: Long-running crawls may timeout; monitor logs
Best Practices
- Run frequently: Schedule every 1-6 hours to ensure timely updates
- Monitor logs: Set up alerts for recrawl errors
- Secure the secret: Use environment variables, never commit to git
- Idempotent calls: Safe to call multiple times; won’t duplicate work
- Database backups: Ensure Supabase backups are enabled
Related Endpoints
- WebSocket Crawl - Enable auto-update when generating llms.txt
- Webhooks - Trigger immediate recrawl for specific site