How do I invalidate response cache?

Options
I like that I can cache responses, but sometimes I need to delete/add/edit a record which invalidates the cache, but the cache does not refresh until TTL runs out.
How do I invalidate a response cache?

Comments

  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    You can't invalidate an existing cached response, but you can add a cache busting input argument.

    For example, you could keep a version counter that changes when you want to guarantee a new fresh result.

    /api/test?v=1
    /api/test?v=2
    /api/test?v=3
  • pete letkeman
    Options
     Okay, yeah I see what I could do, thanks.👍
  • Abdulrahman Hariri
    Abdulrahman Hariri Member
    edited July 2023
    Options

    @Sean Montgomery Thank you Sean.

    I am trying to implement this at the moment and I was wondering if you could provide more details as to how to implement this?

    I am familiar with Xano's basics and I have an initial understanding of what you are suggesting. However, I'd appreciate it if you can provide some brief steps to elaborate a bit.

    For instance,

    • Do I need to create a certain input field? Is this then checked within the function or is the change in the endpoint URL by itself is enough?
    • What's a good practical way to make sure it does reset and that the v is not previously used?

    Many thanks!

  • Ambroise
    Ambroise Member
    Options

    @Abdulrahman Hariri Yeah, you need to use an Input to do that.