Caching
The Expo Open OTA server uses a cache to improve performance and reduce server load by avoiding repeated computations.
Cache Usage
The cache is primarily used for:
-
Storing the computed
lastUpdateIdfor a given platform and runtime version- This prevents the need to recompute the last update for every request, significantly speeding up responses.
-
Caching the computed manifest
- Manifest generation can be an expensive operation.
- By caching the results, we reduce response times and improve overall performance.
The environment variables required for each storage solution are listed below, you can set them in a .env file in the root of the project or keep them in a safe place to prepare for deployment.
- Local cache
- Redis
This cache solution is not recommended for production use. It is intended for development and testing purposes only. If you really want to use it in production, make sure to not have multiple instances of the server running, as the cache is stored locally and not shared between instances.
Local cache is the default cache solution used by the server. It stores the cache in memory and is not shared between instances of the server. This means that the cache is lost when the server is restarted. No additional configuration is required to use the local cache.
To use Redis as your cache solution, you need to set the following environment variables:
REDIS_HOST=your-redis-host
REDIS_PORT=your-redis-port
REDIS_PASSWORD=your-redis-password
REDIS_USE_TLS=true // optional if you are using a TLS connection
REDIS_USERNAME=your-redis-username // optional for ACL authentication
REDIS_CA_CERT_B64=base64-encoded-ca-certificate // optional for TLS with custom CA
If you're using Redis with TLS/SSL and a custom CA certificate:
- Set
REDIS_USE_TLS=true - Set
REDIS_CA_CERT_B64to your base64-encoded PEM certificate - To encode your certificate:
cat certificate.pem | base64 -w 0
If your Redis server uses ACL (Access Control Lists):
- Set
REDIS_USERNAMEto your Redis username - Ensure
REDIS_PASSWORDis set to the corresponding password