Cache Configuration
Document Engine uses two different kinds of caches to improve performance and reduce the load on the asset backend.
Built-In Caches
-
When Document Engine needs to access a PDF file via the asset storage backend, the document is cached on the local file system to speed up future access. You can configure the size of the cache using the
ASSET_STORAGE_CACHE_SIZE
variable. -
When a PSPDFKit for Web client requests a document, Document Engine renders the individual pages and provides them to the client. These pages are cached in memory to speed up future rendering.
Since both caches only work for a single Document Engine node and aren’t shared across multiple Document Engine nodes, you can use Redis to enable a shared cache.
Redis Cache
Document Engine supports usage of Redis as a shared cache for rendered pages. This allows multiple Document Engine nodes to share their work, since only one has to render a document and others will be able to access the cached results. Be aware that this only works with PSPDFKit for Web.
If you’re deploying with Helm, all configuration options can be set through values:
assetStorage: redis: # `USE_REDIS_CACHE` enabled: false # `REDIS_TTL` ttlSeconds: 86400000 # `USE_REDIS_TTL_FOR_PRERENDERING` useTtlForPrerendering: true # `REDIS_HOST` host: redis # `REDIS_PORT` port: 6379 # `REDIS_DATABASE` database: "" # Sentinels sentinel: enabled: false # `REDIS_SENTINELS` urls: [] # - "redis://sentinel1:26379" # - "redis://sentinel2:26379" # - "redis://sentinel3:26379" # `REDIS_SENTINELS_GROUP` group: none # `REDIS_USERNAME` username: "" # `REDIS_PASSWORD` password: "" # `REDIS_SSL` tls: enabled: false # External secret name externalSecretName: ""
Note that you also have to manage and configure Redis. This includes setting the memory limit and setting an eviction policy. We recommend the allkeys-lru
eviction policy for most use cases. Check out this guide on using Redis as an LRU cache for more information.
When moving from a trial license to a production license, we also recommend deleting all cached data, as this will prevent trial overlays from showing up in production.
Document Engine is compatible with any Redis version newer than 2.2.0.
Document Engine only supports single-node Redis deployments and Redis Sentinel deployments. Document Engine cannot be configured to use Redis in cluster mode.
Prerendering
Refer to the documentation on the prerendering endpoint to find out how you can render and cache documents in advance to speed up the loading of your documents even more.