## SoupCache SoupCache — Caching support |

## Functions

SoupCache * | soup_cache_new ()
void | soup_cache_flush ()
void | soup_cache_clear ()
void | soup_cache_dump ()
void | soup_cache_load ()
guint | soup_cache_get_max_size ()
void | soup_cache_set_max_size ()

## Properties

gchar * | cache-dir | Read / Write / Construct Only
SoupCacheType | cache-type | Read / Write / Construct Only

## Types and Values

struct | SoupCache
enum | SoupCacheType

## Object Hierarchy

        GObject
        ╰── SoupCache

## Implemented Interfaces

SoupCache implements SoupSessionFeature and SoupContentProcessor.

## Includes

    #include <libsoup/soup.h>

## Description

SoupCache implements a file-based cache for HTTP resources.

## Functions

### soup_cache_new ()

    SoupCache *
    soup_cache_new (const char *cache_dir,
                    SoupCacheType cache_type);

Creates a new SoupCache.

#### Parameters

cache_dir | the directory to store the cached data, or `NULL` to use the default one. Note that since the cache isn't safe to access for multiple processes at once, and the default directory isn't namespaced by process, clients are strongly discouraged from passing `NULL`. | [allow-none]
cache_type | the SoupCacheType of the cache |

#### Returns

a new SoupCache

Since: 2.34

### soup_cache_flush ()

    void
    soup_cache_flush (SoupCache *cache);

This function will force all pending writes in the `cache` to be committed to disk. For doing so it will iterate the GMainContext associated with `cache` 's session as long as needed.

Contrast with `soup_cache_dump()`, which writes out the cache index file.

#### Parameters

cache | a SoupCache |

Since: 2.34

### soup_cache_clear ()

    void
    soup_cache_clear (SoupCache *cache);

Will remove all entries in the `cache` plus all the cache files.

#### Parameters

cache | a SoupCache |

Since: 2.34

### soup_cache_dump ()

    void
    soup_cache_dump (SoupCache *cache);

Synchronously writes the cache index out to disk. Contrast with `soup_cache_flush()`, which writes pending cache entries to disk.

You must call this before exiting if you want your cache data to persist between sessions.

#### Parameters

cache | a SoupCache |

Since: 2.34.

### soup_cache_load ()

    void
    soup_cache_load (SoupCache *cache);

Loads the contents of `cache` 's index into memory.

#### Parameters

cache | a SoupCache |

Since: 2.34

### soup_cache_get_max_size ()

    guint
    soup_cache_get_max_size (SoupCache *cache);

Gets the maximum size of the cache.

#### Parameters

cache | a SoupCache |

#### Returns

the maximum size of the cache, in bytes.

Since: 2.34

### soup_cache_set_max_size ()

    void
    soup_cache_set_max_size (SoupCache *cache,
                             guint max_size);

Sets the maximum size of the cache.

#### Parameters

cache | a SoupCache |
max_size | the maximum size of the cache, in bytes |

Since: 2.34

## Types and Values

### struct SoupCache

    struct SoupCache;

### enum SoupCacheType

The type of cache; this affects what kinds of responses will be saved.

#### Members

SOUP_CACHE_SINGLE_USER | a single-user cache |
SOUP_CACHE_SHARED | a shared cache |

Since: 2.34

## Property Details

### The `“cache-dir”` property

      “cache-dir”                gchar *

The directory to store the cache files.

Flags: Read / Write / Construct Only

Default value: NULL

### The `“cache-type”` property

      “cache-type”               SoupCacheType

Whether the cache is private or shared.

Flags: Read / Write / Construct Only

Default value: SOUP_CACHE_SINGLE_USER