Context caching pricing explanation

What the point of charging storage price?
Whats preventing me from deleting the cache, and create a new one everytime I generate content?

// Use the cache for generating content.
    response, err := client.Models.GenerateContent(
        ctx,
        modelName,
        genai.Text("Please summarize this transcript"),
        &genai.GenerateContentConfig{
          CachedContent: cache.Name,
        },
    )

@Pianisimo

welcome to the community,

you can most definetly use this approach, if you know how much time this “Generate Content” will take in your case.

if for example , you think that your response will take about 10 secs, you can assign this as TTL during the cache creation and use the cache content for a reduced price and you will be charged for those 10 secs for on a prorated basis.

do understand that after the TTL has passed , the cache will not be avilable for the model to infer and might result in errors so make sure you know your chace to inference time as well while planning this (and then add some more to be on the safer side. :slight_smile: )