# Cache Reserve ## Get Cache Reserve setting `client.Cache.CacheReserve.Get(ctx, query) (*CacheReserveGetResponse, error)` **get** `/zones/{zone_id}/cache/cache_reserve` Increase cache lifetimes by automatically storing all cacheable files into Cloudflare's persistent object storage buckets. Requires Cache Reserve subscription. Note: using Tiered Cache with Cache Reserve is highly recommended to reduce Reserve operations costs. See the [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) for more information. ### Parameters - `query CacheReserveGetParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type CacheReserveGetResponse struct{…}` - `ID CacheReserve` The identifier of the caching setting. - `const CacheReserveCacheReserve CacheReserve = "cache_reserve"` - `Editable bool` Whether the setting is editable. - `Value CacheReserveGetResponseValue` Value of the Cache Reserve zone setting. - `const CacheReserveGetResponseValueOn CacheReserveGetResponseValue = "on"` - `const CacheReserveGetResponseValueOff CacheReserveGetResponseValue = "off"` - `ModifiedOn Time` Last time this setting was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) cacheReserve, err := client.Cache.CacheReserve.Get(context.TODO(), cache.CacheReserveGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", cacheReserve.ID) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "editable": true, "id": "cache_reserve", "value": "off" }, "success": true } ``` ## Change Cache Reserve setting `client.Cache.CacheReserve.Edit(ctx, params) (*CacheReserveEditResponse, error)` **patch** `/zones/{zone_id}/cache/cache_reserve` Increase cache lifetimes by automatically storing all cacheable files into Cloudflare's persistent object storage buckets. Requires Cache Reserve subscription. Note: using Tiered Cache with Cache Reserve is highly recommended to reduce Reserve operations costs. See the [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) for more information. ### Parameters - `params CacheReserveEditParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Value param.Field[CacheReserveEditParamsValue]` Body param: Value of the Cache Reserve zone setting. - `const CacheReserveEditParamsValueOn CacheReserveEditParamsValue = "on"` - `const CacheReserveEditParamsValueOff CacheReserveEditParamsValue = "off"` ### Returns - `type CacheReserveEditResponse struct{…}` - `ID CacheReserve` The identifier of the caching setting. - `const CacheReserveCacheReserve CacheReserve = "cache_reserve"` - `Editable bool` Whether the setting is editable. - `Value CacheReserveEditResponseValue` Value of the Cache Reserve zone setting. - `const CacheReserveEditResponseValueOn CacheReserveEditResponseValue = "on"` - `const CacheReserveEditResponseValueOff CacheReserveEditResponseValue = "off"` - `ModifiedOn Time` Last time this setting was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.Cache.CacheReserve.Edit(context.TODO(), cache.CacheReserveEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Value: cloudflare.F(cache.CacheReserveEditParamsValueOn), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ID) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "editable": true, "id": "cache_reserve", "value": "on" }, "success": true } ``` ## Get Cache Reserve Clear `client.Cache.CacheReserve.Status(ctx, query) (*CacheReserveStatusResponse, error)` **get** `/zones/{zone_id}/cache/cache_reserve_clear` You can use Cache Reserve Clear to clear your Cache Reserve, but you must first disable Cache Reserve. In most cases, this will be accomplished within 24 hours. You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind that you cannot undo or cancel this operation. ### Parameters - `query CacheReserveStatusParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type CacheReserveStatusResponse struct{…}` You can use Cache Reserve Clear to clear your Cache Reserve, but you must first disable Cache Reserve. In most cases, this will be accomplished within 24 hours. You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind that you cannot undo or cancel this operation. - `ID CacheReserveClear` ID of the zone setting. - `const CacheReserveClearCacheReserveClear CacheReserveClear = "cache_reserve_clear"` - `StartTs Time` The time that the latest Cache Reserve Clear operation started. - `State State` The current state of the Cache Reserve Clear operation. - `const StateInProgress State = "In-progress"` - `const StateCompleted State = "Completed"` - `EndTs Time` The time that the latest Cache Reserve Clear operation completed. - `ModifiedOn Time` Last time this setting was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.Cache.CacheReserve.Status(context.TODO(), cache.CacheReserveStatusParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ID) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "end_ts": "2023-10-02T12:00:00.12345Z", "id": "cache_reserve_clear", "start_ts": "2023-10-02T10:00:00.12345Z", "state": "Completed" }, "success": true } ``` ## Start Cache Reserve Clear `client.Cache.CacheReserve.Clear(ctx, params) (*CacheReserveClearResponse, error)` **post** `/zones/{zone_id}/cache/cache_reserve_clear` You can use Cache Reserve Clear to clear your Cache Reserve, but you must first disable Cache Reserve. In most cases, this will be accomplished within 24 hours. You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind that you cannot undo or cancel this operation. ### Parameters - `params CacheReserveClearParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Body param.Field[unknown]` Body param ### Returns - `type CacheReserveClearResponse struct{…}` You can use Cache Reserve Clear to clear your Cache Reserve, but you must first disable Cache Reserve. In most cases, this will be accomplished within 24 hours. You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind that you cannot undo or cancel this operation. - `ID CacheReserveClear` ID of the zone setting. - `const CacheReserveClearCacheReserveClear CacheReserveClear = "cache_reserve_clear"` - `StartTs Time` The time that the latest Cache Reserve Clear operation started. - `State State` The current state of the Cache Reserve Clear operation. - `const StateInProgress State = "In-progress"` - `const StateCompleted State = "Completed"` - `EndTs Time` The time that the latest Cache Reserve Clear operation completed. - `ModifiedOn Time` Last time this setting was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.Cache.CacheReserve.Clear(context.TODO(), cache.CacheReserveClearParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: map[string]interface{}{ }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ID) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "id": "cache_reserve_clear", "start_ts": "2023-10-02T10:00:00.12345Z", "state": "In-progress" }, "success": true } ``` ## Domain Types ### Cache Reserve - `type CacheReserve string` The identifier of the caching setting. - `const CacheReserveCacheReserve CacheReserve = "cache_reserve"` ### Cache Reserve Clear - `type CacheReserveClear string` ID of the zone setting. - `const CacheReserveClearCacheReserveClear CacheReserveClear = "cache_reserve_clear"` ### State - `type State string` The current state of the Cache Reserve Clear operation. - `const StateInProgress State = "In-progress"` - `const StateCompleted State = "Completed"`