List icon Contents

Cache

This guide describes how to work with Chromium cache in JxBrowser.

HTTP cache

The HTTP cache stores the resources fetched from the web. Each profile maintains its own separate HTTP cache:

Java
Kotlin

var cache = profile.httpCache();

val cache = profile.httpCache()

The Engine.httpCache() method returns the HttpCache service of the default profile.

Persistent cache location

Chromium caches data on disk and in memory, automatically determining how to split data between the two.

The disk cache is stored in the user data directory:

/<user-data-directory>/<profile name>/Cache/

Incognito mode

In the Incognito mode, Chromium stores the cache only in memory. The cache is alive until you delete the Profile or close Engine.

Maximum cache size

The maximum cache size is dynamically calculated by Chromium when it starts. You can override this value by using the diskCacheSize(long) engine option:

Java
Kotlin

var engine = Engine.newInstance(
        EngineOptions.newBuilder(renderingMode)
                .diskCacheSize(33554432) // 32 Mb.
                .build()
);

val engine = Engine(renderingMode) {
    diskCacheSize = 33554432 // 32 Mb.
}

If the disk cache size is zero, Chromium will ignore it and calculate its own value instead.

Clearing HTTP cache

Use the asynchronous HttpCache.clear() method to clear the HTTP cache:

Java
Kotlin

profile.httpCache().clear().join();

profile.httpCache().clear().join()

HTTP auth cache

The HTTP authentication cache stores information about authentication identities and challenges. Each profile maintains its own separate authentication cache:

Java
Kotlin

var cache = profile.httpAuthCache();

val cache = profile.httpAuthCache()

The Engine.httpAuthCache() method returns the HttpCache service of the default profile.

To clear the authentication cache, use the HttpAuthCache.clear() method:

Java
Kotlin

profile.httpAuthCache().clear();

profile.httpAuthCache().clear()