Selecting a different order for the same filter selection affects not using cache

Hello,

I have a dashboard with three text filters and only one of them (named modality filter) has multiselect enabled. In this filter the user can choose up to 11 values ​​(by default these values ​​are already selected).

I used the API to save the results of the 11 values ​in the cache ​as some cards take a long time to load.
It worked fine and the cards are loaded immediately when the default filter is not changed.

However, if the user deselects all values ​​and reselects them all in an order different from the order saved in the default filtering, Metabase understands that it is a new selection different from the default one.

Just to illustrate this scenario, instead of using all 11 values ​​in the filter, I used the API to save the results of 2 values ​​selected in the modality filter, first checking the values ​​"Sports" and then "Work" in this filter selection.

However, if I check first "Work" and then "Sports", the entry for the metabase API is quite different and for that reason the cache is probably not used even though the parameters are the same.

Here are the in-browser URLs for both scenarios:

  1. https://myhost/metabase/dashboard/11-dashboard?start_year=2001&end_year=2023&modality=Sports&modality=Work

  2. https://myhost/metabase/dashboard/11-dashboard?start_year=2001&end_year=2023&modality=Work&modality=Sports

and the cURL commands:

  1. curl "https://myhost/metabase/api/dashboard/11/dashcard/97/card/102/query" ^
    -H "Accept: application/json" ^
    -H "Connection: keep-alive" ^
    -H "Content-Type: application/json" ^
    -H "Origin: https://myhost" ^
    -H "Referer: https://myhost/metabase/dashboard/11-dashborad?start_year=2023&end_year=2023&modality=Sports&modalidade=Work" ^
    -H "Sec-Fetch-Dest: empty" ^
    -H "Sec-Fetch-Mode: cors" ^
    -H "Sec-Fetch-Site: same-origin" ^
    -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36" ^
    -H "dnt: 1" ^
    -H "sec-ch-ua: ^^"Not/A)Brand^^";v=^^"99^^", ^^"Google Chrome^^";v=^^"115^^", ^^"Chromium^^";v=^^"115^^"" ^
    -H "sec-ch-ua-mobile: ?0" ^
    -H "sec-ch-ua-platform: ^^"Windows^^"" ^
    --data-raw "^{^^"parameters^^":^[^{^^"type^^":^^"string/=^^",^^"value^^":^[^^"2001^^"^],^^"id^^":^^"ccd8cf72^^",^^"target^^":^[^^"variable^^",^[^^"template-tag^^",^^"start^^"^]^]^},^{^^"type^^":^^"string/=^^",^^"value^^":^[^^"2023^^"^],^^"id^^":^^"399f40f1^^",^^"target^^":^[^^"variable^^",^[^^"template-tag^^",^^"end^^"^]^]^},^{^^"type^^":^^"string/=^^",^^"value^^":^[^^"Sports",^^"Work"^],^^"id^^":^^"29ebf062^^",^^"target^^":^[^^"dimension^^",^[^^"template-tag^^",^^"modality^^"^]^]^}^],^^"dashboard_id^^":11^}" ^
    --compressed

  2. curl "https://myhost/metabase/api/dashboard/11/dashcard/97/card/102/query" ^
    -H "Accept: application/json" ^
    -H "Connection: keep-alive" ^
    -H "Content-Type: application/json" ^
    -H "Origin: https://myhost" ^
    -H "Referer: https://myhost/metabase/dashboard/11-dashborad?start_year=2023&end_year=2023&modality=Work&modalidade=Sports" ^
    -H "Sec-Fetch-Dest: empty" ^
    -H "Sec-Fetch-Mode: cors" ^
    -H "Sec-Fetch-Site: same-origin" ^
    -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36" ^
    -H "dnt: 1" ^
    -H "sec-ch-ua: ^^"Not/A)Brand^^";v=^^"99^^", ^^"Google Chrome^^";v=^^"115^^", ^^"Chromium^^";v=^^"115^^"" ^
    -H "sec-ch-ua-mobile: ?0" ^
    -H "sec-ch-ua-platform: ^^"Windows^^"" ^
    --data-raw "^{^^"parameters^^":^[^{^^"type^^":^^"string/=^^",^^"value^^":^[^^"2001^^"^],^^"id^^":^^"ccd8cf72^^",^^"target^^":^[^^"variable^^",^[^^"template-tag^^",^^"start^^"^]^]^},^{^^"type^^":^^"string/=^^",^^"value^^":^[^^"2023^^"^],^^"id^^":^^"399f40f1^^",^^"target^^":^[^^"variable^^",^[^^"template-tag^^",^^"end^^"^]^]^},^{^^"type^^":^^"string/=^^",^^"value^^":^[^^"Work",^^"Sports"^],^^"id^^":^^"29ebf062^^",^^"target^^":^[^^"dimension^^",^[^^"template-tag^^",^^"modality^^"^]^]^}^],^^"dashboard_id^^":11^}" ^
    --compressed

Is there a way to deal with this issue as the results are the same when using the same values ​​in the modality filter regardless of their order?

Thanls in advance.

Cache is made with a hashing algorithm, if you change a single comma of a text, the hash will change dramatically. You should consider using model caching instead and reduce the number of rows you’re hitting

Hi @Luiggi, thanks for your reply.
What do you mean when you mention model caching?
How does this differ from Metabase caching?
How can I use it?
Thanks again.

I read about the model caching, but unfortunately I can't use it, as my filter uses a variable and model caching doesn't allow it.