Skip to main content
FastF1’s caching system dramatically improves performance by storing downloaded and processed data locally. This prevents re-downloading the same data and speeds up subsequent runs.

Why Use Caching?

Without caching:
  • Every script run downloads data from F1 APIs
  • Processing and parsing must be repeated
  • You may hit API rate limits
  • Scripts take much longer to run
With caching enabled:
  • Data is downloaded once and reused
  • Processing is done once and stored
  • Scripts run 10-100x faster after first run
  • Reduced load on F1 APIs
It is highly recommended to always enable caching. The performance improvement is substantial, and it helps prevent exceeding API rate limits.

Quick Start

Enable caching at the start of your script:
On subsequent runs with the same data:

Enabling the Cache

enable_cache()

str
required
Path to the directory for storing cached data. The directory must already exist.Supports:
  • Absolute paths: '/home/user/fastf1_cache'
  • Home directory: '~/fastf1_cache'
  • Environment variables: '%LOCALAPPDATA%/fastf1_cache' (Windows)
bool
default:"False"
If True, uses cached data even if it was created with a different FastF1 version.
Not recommended - incompatible cached data may cause crashes or errors.
bool
default:"False"
If True, ignores all existing cached data and downloads fresh data.
bool
default:"True"
Enable caching of raw HTTP requests (stage 1 cache).

Example Usage

Cache Location

You can specify the cache location in three ways (in order of precedence):

1. Explicit Configuration

Call enable_cache() with a path:

2. Environment Variable

Set the FASTF1_CACHE environment variable:
Then in your script:

3. Default Location

If neither is specified, FastF1 uses an OS-dependent default:
%LOCALAPPDATA%\Temp\fastf1Typically: C:\Users\YourName\AppData\Local\Temp\fastf1
~/Library/Caches/fastf1Full path: /Users/YourName/Library/Caches/fastf1
~/.cache/fastf1 (if ~/.cache exists)Otherwise: ~/.fastf1
When using the default cache location, FastF1 will create the directory automatically and display a warning message.

How Caching Works

FastF1 uses a two-stage caching system:

Stage 1: HTTP Request Cache

Raw GET and POST requests are cached in a SQLite database:
  • File: fastf1_http_cache.sqlite in the cache directory
  • Caches raw API responses
  • Applies cache control and expiration (12 hours by default)
  • Reduces network requests

Stage 2: Parsed Data Cache

Processed and parsed data is cached as pickle files:
  • Files: *.ff1pkl in session-specific subdirectories
  • Caches Python objects after parsing
  • Saves computation time
  • Organized by year/event/session

Cache Information

Get information about the current cache:

Managing the Cache

Clearing the Cache

Delete all cached data:
You can call clear_cache() without enabling the cache first.

Manual Cache Management

You can manually delete cache files:

Cache Size Management

The cache can grow large over time. Typical sizes:
  • Single qualifying session: 5-15 MB
  • Single race: 20-50 MB
  • Full season (all sessions): 3-8 GB
To manage size:
  1. Clear old/unused data regularly
  2. Use selective loading (disable telemetry if not needed)
  3. Store cache on a drive with sufficient space

Temporarily Disabling Cache

Disable caching for specific code sections:

Using Context Manager

Manual Control

Offline Mode

Work with cached data without internet:
Useful for:
  • Working without internet connection
  • Ensuring reproducible results
  • Preventing accidental data updates

Performance Benefits

Real-world performance comparison:

Without Cache

With Cache (First Run)

With Cache (Subsequent Runs)

Advanced Features

CI Mode

For continuous integration environments:

Version Handling

When FastF1 is updated, cached data from older versions may be incompatible:

Best Practices

Start every script with cache enablement:
Don’t mix cache files with your project files:
Ensure the directory exists before enabling cache:
Clean up cache for sessions you no longer need:
Check cache size periodically:

Troubleshooting

Cache Not Working

If caching doesn’t seem to work:
  1. Verify directory exists
  2. Check cache is enabled
  3. Verify files are created

Version Mismatch Errors

If you see version mismatch warnings:

Permission Errors

If you get permission errors: