vercel.functions API Reference (Python)
-
Install the package:
-
Import the package:
Description: Gets the System Environment Variables exposed by Vercel.
Description: Returns the location information for the incoming request, in the following way:
| Name | Type | Description |
|---|---|---|
| The incoming request object which provides the IP |
Description: Returns the IP address of the request from the headers.
| Name | Type | Description |
|---|---|---|
| The incoming request object which provides the IP |
Description: Allows you to interact with the Vercel Runtime Cache in any Vercel region. Use this for storing and retrieving data across function, routing middleware, and build execution within a Vercel region.
| Name | Type | Description |
|---|---|---|
| Optional custom hash function for generating keys. | ||
| Optional namespace to prefix cache keys. | ||
| Optional separator string for the namespace. |
provide the following methods:
| Method | Description | Parameters |
|---|---|---|
| Retrieves a value from the Vercel Runtime Cache. | : The cache key | |
| Stores a value in the Vercel Runtime Cache with optional and/or . The option allows a human-readable label to be associated with the cache entry for observability purposes. |
| |
| Removes a value from the Vercel Runtime Cache by key | : The cache key to delete | |
| Expires all cache entries associated with one or more tags | : Tag or sequence of tags to expire |
Use in async code. It has the same API and uses the same underlying cache as , and exposes awaitable methods.
After assigning tags to your cached data, use the method to invalidate all cache entries associated with that tag. This operation is propagated globally across all Vercel regions within 300ms.
The Runtime Cache is isolated per Vercel project and deployment environment ( and ). Cached data is persisted across deployments and can be invalidated either through time-based expiration or by calling . However, TTL (time-to-live) and tag updates aren't reconciled between deployments. In those cases, we recommend either purging the runtime cache or modifying the cache key.
The Runtime Cache API does not have first class integration with Incremental Static Regeneration. This means that:
- Runtime Cache entry tags will not apply to ISR pages, so you cannot use to invalidate both caches.
- Runtime Cache entry TTLs will have no effect on the ISR revalidation time and
The following Runtime Cache limits apply:
- The maximum size of an item in the cache is 2 MB. Items larger than this will not be cached.
- A cached item can have a maximum of 128 tags.
- The maximum tag length is 256 bytes.
Usage of the Vercel Runtime Cache is charged, learn more about pricing in the regional pricing docs.
Was this helpful?