Method Signature
Parameters
string
required
The cached content resource name to update.Format:
"cachedContents/abc123"UpdateCachedContentConfig
Configuration for the update.Available options:
ttl: New time-to-live duration (e.g.,"3600s"for 1 hour)expire_time: New specific expiration timestamp
Specify either
ttl OR expire_time, not both.Returns
CachedContent
The updated CachedContent object with the new expiration time.Contains:
name: Resource nameexpire_time: Updated expiration timestampupdate_time: When the update occurred- All other cache metadata
Examples
Extend Cache by Duration
Set Specific Expiration Time
Extend Cache for 24 Hours
Conditional Extension
Extend Multiple Caches
Async Update
Extend Cache Before Heavy Usage
Set Cache to Expire at End of Day
Keep-Alive Pattern
Update and Verify
Extend with Maximum TTL
Important Notes
- Only expiration settings can be updated
- The cached content itself (documents, context, etc.) cannot be modified
- To change cached content, you must create a new cache
- Updates reset the
update_timebut notcreate_time
TTL Limits
Different APIs may have different maximum TTL limits:
- Gemini API: Check current documentation for limits
- Vertex AI: May have different limits
Error Handling
API Availability
This method is available in both Gemini API and Vertex AI.
Related Methods
- caches.create - Create a new cache
- caches.get - Get cache metadata
- caches.delete - Delete a cache
- caches.list - List all caches