# Caching Issues with Pre User Registration Action

**URL:** <https://community.auth0.com/t/caching-issues-with-pre-user-registration-action/187496>\
**Category:** Get Help\
**Tags:** other, community-topic\
**Created:** [June 2, 2025, 5:57pm UTC](https://community.auth0.com/t/caching-issues-with-pre-user-registration-action/187496 "2025-06-02T17:57:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Titorr2001](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/titorr2001/32/75109_2.png) [@Titorr2001](https://community.auth0.com/u/Titorr2001)\
**Post date:** [June 2, 2025, 5:57pm UTC](https://community.auth0.com/t/caching-issues-with-pre-user-registration-action/187496/1 "2025-06-02T17:57:28Z")

</div>

Hello!

In my `Post Login` Action, I have code that generates and caches a specific value that can be reused across multiple requests. This works well—when a new login request comes in, I can retrieve the cached value instead of regenerating it.

However, I’m now trying to use the same caching logic in a `Pre User Registration` Action. While Auth0’s documentation says caching is supported in this action, it appears that cached values are only retained for the duration of a single request. When a new registration request comes in, the cached value is no longer available. I am using a new and different cache key to avoid any collision issues as well, but the value still gets lost across multiple requests.

Is there anyone that can answer why this occurs? Is there any way to cache values across multiple requests like the `Post Login` action does?

```auto
exports.onExecutePreUserRegistration = async (event, api) => {
    console.log(' ***Test Cache***');
	console.log(`Test Key At Start value: ${api.cache.get('test')?.value}`);
    api.cache.set('test', 'iamasecretvalue', { ttl: 9999999999 });
	console.log(`Test Key After Being Set value: ${api.cache.get('test')?.value}`);
    console.log(' ************************')

	console.log(" **************End of Pre-Registration Action***************");
};

```

When this action gets hit multiple times across multiple requests, the cache does not contain the value for the `test` key. It is only present in the cache once set for the single request.

---

<div class="post-metadata">

**Author:** ![theresa397ayres](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/theresa397ayres/32/71395_2.png) [@theresa397ayres](https://community.auth0.com/u/theresa397ayres)\
**Post date:** [June 3, 2025, 10:00am UTC](https://community.auth0.com/t/caching-issues-with-pre-user-registration-action/187496/3 "2025-06-03T10:00:06Z")

</div>

Hello,

Your TTL value 9999999999 is extremely large; if persistent caching was available, it would keep the value for a very long time.

Best Regard,  
Theresa

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [June 3, 2025, 5:21pm UTC](https://community.auth0.com/t/caching-issues-with-pre-user-registration-action/187496/4 "2025-06-03T17:21:40Z")

</div>

Hi @Titorr2001

Welcome to the Auth0 Community!

As mentioned in our documentation in regards to the PreUserRegistration Trigger API Object:

> `api.cache.get(key)`
> 
> Retrieve a record describing a cached value at the supplied `key`, if it exists. If a record is found, the cached value can be found at the `value` property of the returned object.
> 
> Returns a cache record if an item is found in the cache for the supplied `key`. Cache records are objects with a `value` property holding the cached value as well as an `expires_at` property indicating the maximum expiry of the record in milliseconds since the Unix epoch.
> 
> **Important:** This cache is designed for short-lived, ephemeral data. Items may not be available in later transactions even if they are within their supplied their lifetime.

It appears that even if you set a prolonged lifetime for the cached value, it is intended behaviour for the cache to not be available in later transactions.

Also, for the `api.cache.set(key, value, [options])` parameters, it appears that the ttl value is available under the `options.ttl` parameter, you might want to try changing that in your code and see if it affects the end result. You can also try changing the `options.expires_at` value.

You can read more about these [here](https://auth0.com/docs/customize/actions/explore-triggers/signup-and-login-triggers/pre-user-registration-trigger/pre-user-registration-api-object).

If you have any other questions, let me know!

Kind Regards,  
Nik

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [June 17, 2025, 5:21pm UTC](https://community.auth0.com/t/caching-issues-with-pre-user-registration-action/187496/5 "2025-06-17T17:21:57Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
