8.3. Configure Image Cache


You can configure the Image service API to have a local image cache. Caching of image files is transparent and can be performed by modifying some configuration parameters.
These parameters are configured in the PasteDeploy configuration file, component-paste.ini. You should not generally edit this file directly, as it ships with default options for all common deployment flavors.

8.3.1. Enable the Image Cache

To enable the image cache parameters, the cache parameters must occur in the application pipeline after the appropriate context parameters.
The cache parameters should be in your glance-api-paste.ini in a section titled [filter:cache]. It should look like this:
[filter:cache]
paste.filter_factory = glance.api.middleware.cache:CacheFilter.factory
Copy to Clipboard Toggle word wrap
A ready-made application parameter including this filter is defined in the glance-api-paste.ini file as follows:
[pipeline:glance-api-caching]
pipeline = versionnegotiation context cache apiv1app
Copy to Clipboard Toggle word wrap
To enable the above application parameter, in your main glance-api.conf configuration file, select the appropriate deployment flavor as follows:
[paste_deploy]
flavor = caching
Copy to Clipboard Toggle word wrap

8.3.2. Enable the Image Cache Management

There is an optional cachemanage option that allows you to directly interact with cache images. Use this flavor in place of the cache flavor in your API config file.
[paste_deploy]
flavor = cachemanage
Copy to Clipboard Toggle word wrap
These configuration options must be set in both the glance-cache and glance-api configuration files.
Expand
Table 8.23. Description of Image Cache configuration options
Configuration option = Default value Description
image_cache_dir = /var/lib/glance/image-cache Required when image cache middleware is enabled. This is the base directory the image cache can write files to. Make sure the directory is writable by the user running the glance-api server.
image_cache_driver = sqlite (Optional) The default sqlite cache driver has no special dependencies, other than the python-sqlite3 library, which is installed on almost all operating systems with modern versions of Python. It stores information about the cached files in a SQLite database.
The xattr cache driver requires the python-xattr>=0.6.0 library and requires that the filesystem containing image_cache_dir has access times tracked for all files (in other words, the noatime option CANNOT be set for that filesystem). In addition, user_xattr must be set on the filesystem’s description line in fstab.
image_cache_sqlite_db = cache.db (Optional) When using the sqlite cache driver, you can set the name of the database that will be used to store the cached images information. The database is always contained in the image_cache_dir .
image_cache_max_size = 10737418240 (10 GB) (Optional) Size, in bytes, that the image cache should be constrained to. Images files are cached automatically in the local image cache, even if the writing of that image file would put the total cache size over this size. The glance-cache-pruner executable is what prunes the image cache to be equal to or less than this value. The glance-cache-pruner executable is designed to be run via cron on a regular basis.
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat