# glance.api.middleware.cache module

Transparent image file caching middleware, designed to live on Glance API nodes. When images are requested from the API node, this middleware caches the returned image file to local filesystem.

When subsequent requests for the same image file are received, the local cached copy of the image file is returned.

class glance.api.middleware.cache.CacheFilter(app)

  Bases: `Middleware`

  get_from_cache(image_id)

    Called if cache hit

  get_status_code(response)

    Returns the integer status code from the response, which can be either a Webob.Response (used in testing) or httplib.Response

  process_request(request)

    For requests for an image file, we check the local image cache. If present, we return the image file, appending the image metadata in headers. If not present, we pass the request on to the next application in the pipeline.

  process_response(resp)

    We intercept the response coming back from the main images Resource, removing image file from the cache if necessary

this page last updated: 2026-03-19 01:38:33

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.

found an error? report a bug