text: Title: Tabs dont respond when using nested cache functions
  Body: ### Checklist
  
  - [X] I have searched the [existing issues](https://github.com/streamlit/streamlit/issues) for similar issues.
  - [X] I added a very descriptive title to this issue.
  - [X] I have provided sufficient information below to help reproduce this issue.
  
  ### Summary
  
  [![Open in Streamlit Cloud](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://issues.streamlitapp.com/?issue=gh-9951)
  
  I detected a critical problem with tabs when updating streamlit to a version newer than 1.35.0 (1.36 and up all have this problem). I found the issue in mobile, but it reproduces also in PC.
  
  In my app I have the following scenario:
  - Multiple tabs
  - Several of them call functions that are cached
  - And those functions call also (sometimes several times) nested cache functions.
  
  In version 1.35 everything works fine on mobile and pc, but when I tried to update to a newer version, I detected that changing between tabs dont work (they become super irresponsibe and the app seems to crash). This is weird because my understanding was that changing tabs didnt trigger any runs/calculations.
  
  If you erase all the @st.cache_data from the reproducible code example, all the code works just fine. So the problem seem to be that streamlit is doing somthing with the cache data when I try to switch tabs.
  
  ### Reproducible Code Example
  
  ```Python
  import streamlit as st
  
  st.header(body = "Testing problem switching tabs")
  
  @st.cache_data(ttl=None)
  def cached_func_level4():
      return "test"
  
  @st.cache_data(ttl=None)
  def cached_func_level3():
      return cached_func_level4()
  
  @st.cache_data(ttl=None)
  def cached_func_level2():
      return cached_func_level3()
  
  @st.cache_data(ttl=None)
  def cached_func_level1():
      return cached_func_level2()
  
  @st.cache_data(ttl=None)
  def cached_func_level0():
      # If you iterate more times than 2000, the tab problem is even bigger
      for _ in range(2000):
          x = cached_func_level1()
      return x
  
  
  # In this testing tabs I only print a value and execute the 
  # "root" cached function, which calls other cached funcs
  admin_tabs = st.tabs(["test1", "test2"])
  
  with admin_tabs[0]:
      st.write("Hello")
      val = cached_func_level0()
  
  with admin_tabs[1]:
      st.write("World!")
      val = cached_func_level0()
  ```
  
  
  ### Steps To Reproduce
  
  Just run streamlit and when the page renders try to switch between the tabs. 
  
  ### Expected Behavior
  
  The expected behavior would be to be able to switch tabs without delay
  
  ### Current Behavior
  
  Now the tabs crash when you try to switch between them, and the app does not respond or it does but super slowly.
  
  ### Is this a regression?
  
  - [X] Yes, this used to work in a previous version.
  
  ### Debug info
  
  - Streamlit version: 1.36 and up
  - Python version: 3.11.5
  - Operating System: Windows and iOS
  - Browser: Testing in both safari and chrome
  
  
  ### Additional Information
  
  _No response_