Speeding up Deploys with Caching
If your Python or Node Repl follows a set of constraints, it’s possible to speed up the Deployment process by enabling package caching. This feature works by caching the language-specific dependencies of your Repl for reuse across deploys.
Prerequisites
Python
- Your Repl uses Python 3.10 or above
- You are using the
poetry
backend for upm. Currently,pip
is not supported for this feature. - All of your projects' dependencies are tracked in your
pyproject.toml
, and you have a currentpoetry.lock
.
Node
- Your project uses npm version 7 or above
Enabling Package Caching
If your Repl follows the prerequisites above, you can try enabling package caching to speed up deploys. To do this, you need to define an environment variable in the .replit
file. For Python Repls, the variable is REPLIT_PYTHON_PACKAGE_LAYER
. For Node Repls, it's REPLIT_NODEJS_PACKAGE_LAYER
.
Set the correct environment variable in the [env]
section of the .replit
file.
[env]
# For Python
REPLIT_PYTHON_PACKAGE_LAYER = "1"
# or For Node
REPLIT_NODEJS_PACKAGE_LAYER = "1"
After the initial Deployment with caching enabled, the build system will cache the dependencies for quicker future Deployments.
Troubleshooting
If your Deployment fails during the Bundle
or Promote
steps, you may need to disable package caching.
To do that, just remove the environment variable definitions from .replit
.