Meta Ads Data Reuse
The Meta Ads connector uses a data reuse mechanism to optimize API requests and reduce load. Caching helps avoid repeated requests for the same data within a single session and across sessions.
How Caching Works
Cache Key
Each request to the Meta Ads API is identified by a unique key formed from:
- Ad account ID (
account_id) - Level of detail (
level: account, campaign, adset, ad) - Period (
date_presetortime_range) - Set of fields (
fields) - Filtering parameters (
filtering) - Breakdowns (
breakdowns)
A match on all parameters means an identical request — the data is returned from the cache without hitting the API.
Cache Lifetime (TTL)
| Data Type | TTL | Reason |
|---|---|---|
| Today's data | 5 minutes | Data is actively updating |
| Yesterday's data | 30 minutes | Minor changes due to attribution |
| Data older than 2 days | 1 hour | Data is stable |
| Structural data (campaigns, ad sets) | 15 minutes | Rarely changes |
| Asynchronous reports | Until the report expires (24 hours) | Results don't change |
Cache Invalidation
The cache is automatically invalidated in the following cases:
- Manual refresh: the user clicked "Refresh data"
- Period change: a request with a new
date_presetortime_range - Configuration change: filters, breakdowns, or fields are changed
- TTL exceeded: the data is considered outdated by time
Caching Strategy
Progressive Caching
LightLead uses a progressive caching strategy:
- First request: data is loaded from the API and saved to the cache
- Repeat request: data is returned from the cache if the TTL hasn't expired
- Background refresh: as the TTL nears its end, a background refresh is triggered
Hierarchical Caching
Data is cached at different levels:
- Request level: the result of a specific API request
- Entity level: data for individual campaigns, ad sets, ads
- Metadata level: lists of accounts, pages, Instagram accounts
When metadata changes (e.g. a campaign is renamed), only the corresponding cache level is invalidated.
Benefits of Data Reuse
- Reduced API load: fewer requests → lower chance of throttling
- Faster response: cached data is returned instantly
- Quota savings: doesn't consume Meta API request limits
- Stability: cached data can be used during temporary API unavailability
Caching Limitations
- Not for real-time: caching is not suitable for real-time dashboards
- Memory: the cache consumes RAM
- Consistency: if data changes in Ads Manager, the cache may serve stale data until the TTL expires
Forced Refresh
To get the most up-to-date data, use the Refresh button in the LightLead interface. This forcibly invalidates the cache and performs a new API request.