<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSImage/CacheMode-swift.enum",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:@E@NSImageCacheMode"
  },
  "title" : "NSImage.CacheMode"
}
-->

# NSImage.CacheMode

Constants that specify the caching policy on a per-image basis.

```
enum CacheMode
```

## Overview

Set the caching policy using the [`cacheMode`](/documentation/AppKit/NSImage/cacheMode-swift.property) property.

The following table specifies the default caching policy for the various types of image representation.

|Image Rep Class   |Default caching policy                                                                                                   |
|------------------|-------------------------------------------------------------------------------------------------------------------------|
|`NSBitmapImageRep`|`NSImageCacheBySize`. Cache if bitmap is 32-bits in 16-bit world or greater than 72 dpi.                                 |
|`NSPICTImageRep`  |`NSImageCacheBySize`. Same reasoning as `NSBitmapImageRep` in the event the PICT contains a bitmap.                      |
|`NSPDFImageRep`   |`NSImageCacheAlways`                                                                                                     |
|`NSCIImageRep`    |`NSImageCacheBySize`. Cache if the bitmap depth does not match the screen depth or the resolution is greater than 72 dpi.|
|`NSEPSImageRep`   |`NSImageCacheAlways`                                                                                                     |
|`NSCustomImageRep`|`NSImageCacheAlways`                                                                                                     |

## Topics

### Cache Options

[`NSImageCacheDefault`](/documentation/AppKit/NSImage/CacheMode-swift.enum/default)

Caching is unspecified.

[`NSImageCacheAlways`](/documentation/AppKit/NSImage/CacheMode-swift.enum/always)

Always generate a cache when drawing.

[`NSImageCacheBySize`](/documentation/AppKit/NSImage/CacheMode-swift.enum/bySize)

Cache if the cache size is smaller than the original data.

[`NSImageCacheNever`](/documentation/AppKit/NSImage/CacheMode-swift.enum/never)

Never cache; always draw direct.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Hashable`](/documentation/Swift/Hashable)

[`BitwiseCopyable`](/documentation/Swift/BitwiseCopyable)

[`RawRepresentable`](/documentation/Swift/RawRepresentable)

[`Equatable`](/documentation/Swift/Equatable)

[`Sendable`](/documentation/Swift/Sendable)

---

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)