How can I use a cached collection with variables?

A three part question which I hope someone can help me with.

I’d like to use a cached data set.

  1. There is not too much documentation about how this can be done.
    I have concluded that I need to create an object type variable and somehow get the data into it.
    Will you provide some documentation or a video on how to do this?

  2. The API that has the cached data I want to connect to requires authentication.
    Normally I’d use the XANO Auth Token from the XANO auth plugin, but you cannot use variables for any field values in this dialog

  1. I’d like to use a variable for the API end point just incase if changes in the future, but you cannot use variables in the URL like you can for a non cached API request.

Hi @peteletkemansst,

Firstly, you have this documentation that explain what is the cached collection: 🎭 Data Collection Types

  1. I don’t understand why you want to create and object type variable. Could you explain me?

    1. It’s normal to don’t have bindable url and parameter for cached collection, because you don’t want to have this collection change dynamically. If you select dynamic, you will see all url and parameter bindable

Thank you for the link to the documentation.

If you are using a data source like Xano then you can specify the data source with X-Data-Source either as a query string or a post value for instance xano.com?x-data-source=test.

Plus, I’ve experienced that sometimes a data source has to be moved from one site to another site e.g. xano.com/randomValue1?name=petexano.com/randomValue2?name=pete.
Therefore moving xano.com/randomValue1 to a variable make sense.

Also, if you are working on a multi user site with different groups of users e.g. Admin, Location Manager, Public User then a cached collection would be different for each different group.

To add to this how can I add an authentication header?
Does this have to be a hard coded account or publicly available to everyone?

Hello

The cached collection are not for this type of use case. It’s more to use data that are behind an API rate limit

I think what you are looking for is this (we just release this new feature):

It will work if you use the Xano plugin for your cached collection

The new link to the doc is Creating a collection | Weweb documentation.

I’m still unsure about using Dynamic vs Cached. I understand when to prefer Cached (I use Airtable), but I don’t understand what the you'll need to refresh the data yourself when it changes means for my app. What concrete steps do I must follow to do that? How do I refresh the data of a collection manually? Can I do it for a single record?

When configuring the collection, you’ll see this section. If you click on one of the “Hooks to sync WeWeb cache” button, it’ll copy the webhook URL. You can then use any workflow to trigger the refresh by calling that URL.

3 Likes

This is new, and it’s awesome!