<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Layout/updateCache(_:subviews:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI6LayoutP11updateCache_8subviewsy0E0Qzz_AA0C8SubviewsVtF"
  },
  "title" : "updateCache(_:subviews:)"
}
-->

# updateCache(_:subviews:)

Updates the layout’s cache when something changes.

```
func updateCache(_ cache: inout Self.Cache, subviews: Self.Subviews)
```

## Parameters

`cache`

Storage for calculated data that you share among
the methods of your custom layout container.

`subviews`

A collection of proxy instances that represent the
views arranged by the container. You can use the proxies in the
collection to get information about the subviews as you
calculate values to store in the cache.

## Discussion

If your custom layout container creates a cache by implementing the
[`makeCache(subviews:)`](/documentation/SwiftUI/Layout/makeCache(subviews:)) method, SwiftUI calls the update method
when your layout or its subviews change, giving you an opportunity
to modify or invalidate the contents of the cache.
The method’s default implementation recreates the
cache by calling the [`makeCache(subviews:)`](/documentation/SwiftUI/Layout/makeCache(subviews:)) method,
but you can provide your own implementation to take an
incremental approach, if appropriate.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)