[Resolved] Element Cache

Home Forums Support [Resolved] Element Cache

Home Forums Support Element Cache

  • This topic has 3 replies, 2 voices, and was last updated 5 years ago by Tom.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #870784
    Matthew

    I’m displaying dynamic content in a few elements and the dynamic content requires a few database hits using WP_query. Is there a way to cache the output. Maybe a way so the entire element is cached for a user-defined period of time (ex., 24 hours)? When the period of time expires, the element is refreshed. I don’t think this is done already and it could save a lot of resources on my end.

    #870975
    Tom
    Lead Developer
    Lead Developer

    There isn’t a way to cache an element, but you could cache your WP_Query results.

    For example, run a function in the init hook, and set your query results in update_option() or set_transient().

    Then in the element, call the results using get_option() or get_transient().

    #870980
    Matthew

    Thanks. I’ll give that a shot. But maybe you guys could implement element caching and a custom user timer down the road? If not though, np. Thanks!

    #870998
    Tom
    Lead Developer
    Lead Developer

    I’ll definitely give it some thought!

    Thanks 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.