# Caching in Actions

**URL:** <https://community.auth0.com/t/caching-in-actions/93435>\
**Category:** Product Feedback\
**Tags:** actions\
**Created:** [September 7, 2022, 9:59am UTC](https://community.auth0.com/t/caching-in-actions/93435 "2022-09-07T09:59:08Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![avnish](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/avnish/32/33630_2.png) [@avnish](https://community.auth0.com/u/avnish)\
**Post date:** [September 7, 2022, 9:59am UTC](https://community.auth0.com/t/caching-in-actions/93435/1 "2022-09-07T09:59:08Z")

</div>

I have the same need. The use case is to call custom API from auth0 action.

---

<div class="post-metadata">

**Author:** ![vigi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vigi/32/12799_2.png) [@vigi](https://community.auth0.com/u/vigi)\
**Post date:** [September 26, 2022, 5:10pm UTC](https://community.auth0.com/t/caching-in-actions/93435/2 "2022-09-26T17:10:08Z")

</div>

Really disappointed that caching isn’t available in Actions like in Rules. Back to rules I suppose.

---

<div class="post-metadata">

**Author:** ![nick.silvestri](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nick.silvestri/32/35706_2.png) [@nick.silvestri](https://community.auth0.com/u/nick.silvestri)\
**Post date:** [October 31, 2022, 7:14pm UTC](https://community.auth0.com/t/caching-in-actions/93435/3 "2022-10-31T19:14:40Z")

</div>

This seems like a fundamentally missing feature from actions. With token caching being recommended across Auth0 documentation, it seems like a complete oversight to not support it in the platform itself, especially when there’s a big warning on the top of the Rules page, which would be the cacheable alternative.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [October 31, 2022, 9:26pm UTC](https://community.auth0.com/t/caching-in-actions/93435/4 "2022-10-31T21:26:35Z")

</div>

Hi all, I moved these requests to their own feedback item specific for a _caching mechanism in Actions._

On this front, our team is actively investigating a solution for this. Stay tuned for more info.

---

<div class="post-metadata">

**Author:** ![matheus.souza](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/matheus.souza/32/38045_2.png) [@matheus.souza](https://community.auth0.com/u/matheus.souza)\
**Post date:** [June 15, 2022, 1:19pm UTC](https://community.auth0.com/t/caching-in-actions/93435/5 "2022-06-15T13:19:23Z")

</div>

I have the same need!  
Is there a way to cache on auth0 actions?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [November 28, 2022, 2:18pm UTC](https://community.auth0.com/t/caching-in-actions/93435/6 "2022-11-28T14:18:23Z")

</div>

Hi folks, this feature is now live!

Read more here: [Actions Caching Is Now Available](https://auth0.com/blog/actions-caching-is-now-available/)

---

<div class="post-metadata">

**Author:** ![dominik.wloadarz](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dominik.wloadarz/32/33985_2.png) [@dominik.wloadarz](https://community.auth0.com/u/dominik.wloadarz)\
**Post date:** [December 5, 2022, 6:57am UTC](https://community.auth0.com/t/caching-in-actions/93435/7 "2022-12-05T06:57:39Z")

</div>

According to this article ([Actions Limitations](https://auth0.com/docs/customize/actions/limitations)), the overall cache size is 8192 bytes. It means that not too many tokens can be stored there. Could you also provide a working sample of an Action that implements this feature?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [December 5, 2022, 2:32pm UTC](https://community.auth0.com/t/caching-in-actions/93435/8 "2022-12-05T14:32:04Z")

</div>

@dominik.wloadarz, we are working on an example FAQ. We can post it here when it is published.

cc: @ty.frith

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [December 7, 2022, 1:16am UTC](https://community.auth0.com/t/caching-in-actions/93435/9 "2022-12-07T01:16:52Z")

</div>

@dominik.wloadarz Here’s an FAQ with a rudimentary example:

[https://community.auth0.com/t/caching-management-api-access-tokens-in-login-action/95855](https://community.auth0.com/t/caching-management-api-access-tokens-in-login-action/95855)

Note that you also have the ability to remove tokens from cache with `api.cache.delete(key)` - See documentation here:

> **[Actions Triggers: post-login - API Object - Auth0 Docs](https://auth0.com/docs/customize/actions/explore-triggers/signup-and-login-triggers/login-trigger/post-login-api-object)**
>
> Learn about the post-login Action trigger's API object.

---

<div class="post-metadata">

**Author:** ![dominik.wloadarz](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dominik.wloadarz/32/33985_2.png) [@dominik.wloadarz](https://community.auth0.com/u/dominik.wloadarz)\
**Post date:** [December 7, 2022, 7:10am UTC](https://community.auth0.com/t/caching-in-actions/93435/10 "2022-12-07T07:10:34Z")

</div>

According to the implementation it seems that one would be capable of storing maybe up to 8 tokens (assumption 1 jwt == 1kB) and that’s it (action limitations → 8kB of cache). So in a M2M scenario 1 API would be able to use up to 8 clients?

---

<div class="post-metadata">

**Author:** ![ryan.fielding](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ryan.fielding/32/35918_2.png) [@ryan.fielding](https://community.auth0.com/u/ryan.fielding)\
**Post date:** [December 13, 2022, 8:19am UTC](https://community.auth0.com/t/caching-in-actions/93435/11 "2022-12-13T08:19:14Z")

</div>

Agreed - this seems like a big limitation considering the use case it is supposed to be addressing.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [December 13, 2022, 3:43pm UTC](https://community.auth0.com/t/caching-in-actions/93435/12 "2022-12-13T15:43:00Z")

</div>

@dominik.wloadarz @ryan.fielding,

Thanks for the feedback. Are you running into issues with the cache size limits in practice? The cache is ephemeral, so it may not be holding all those tokens at once.

Also, could you please expand on the following use case?

> [@dominik.wloadarz](#):
>
> So in a M2M scenario 1 API would be able to use up to 8 clients?

---

<div class="post-metadata">

**Author:** ![jhu7](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jhu7/32/33232_2.png) [@jhu7](https://community.auth0.com/u/jhu7)\
**Post date:** [December 16, 2022, 12:18am UTC](https://community.auth0.com/t/caching-in-actions/93435/13 "2022-12-16T00:18:52Z")

</div>

According to the documentation action cache only persists 15 minutes. M2M tokens usually are valid for much longer (12-24 hours), let’s say I want to limit each client to 5 m2m token requests per day, action cache still can’t help me achieve that.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [December 16, 2022, 3:40pm UTC](https://community.auth0.com/t/caching-in-actions/93435/14 "2022-12-16T15:40:50Z")

</div>

> [@jhu7](#):
>
> let’s say I want to limit each client to 5 m2m token requests per day, action cache still can’t help me achieve that.

Thanks for expanding.

This feature addresses token requests on every individual action execution and brings parity to the existing token cache feature in our legacy solution, Rules. You are correct, it will not provide a long-lived cache.

---

<div class="post-metadata">

**Author:** ![jhu7](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jhu7/32/33232_2.png) [@jhu7](https://community.auth0.com/u/jhu7)\
**Post date:** [December 18, 2022, 11:53pm UTC](https://community.auth0.com/t/caching-in-actions/93435/15 "2022-12-18T23:53:52Z")

</div>

Thanks for the response Dan. Are there any plans on the dev roadmap to provide built-in solutions for auth0 users to control m2m requests on finer scale (per application)? It always makes us nervous knowing someone may put on a loop and exhaust our quota for m2m token requests

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [December 27, 2022, 3:01pm UTC](https://community.auth0.com/t/caching-in-actions/93435/16 "2022-12-27T15:01:31Z")

</div>

@jhu7

There is a request for it here: [Add rate limiting and cache for m2m token authentication endpoints](https://community.auth0.com/t/add-rate-limiting-and-cache-for-m2m-token-authentication-endpoints/75367)

Feel free to add context to that thread.

---

<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:** [January 19, 2023, 2:35pm UTC](https://community.auth0.com/t/caching-in-actions/93435/18 "2023-01-19T14:35:00Z")

</div>

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