Question

Caching Dashboards With Scheduler

  • 2 December 2016
  • 16 replies
  • 2332 views

Userlevel 1

How does caching work with dashboards. I believe if it is still cached and a scheduled dashboard email is sent out, it will use the cache? Is there a way to force it to clear the cache before send of a scheduled task?


I would like to have my cache set for longer periods so when users come it is cached, but the issue I believe is that also affects scheduled emails as well and I want the cache to clear whenever a scheduled job is sent so it has the most relevant data and also creates a new cache for incoming users.


16 replies

Userlevel 1

And is the logic for caching the same for both scheduled dashboards and looks?

Regarding your first post, having the ability to clear the cache from a scheduled email job is something the Looker Product team is working on, but until there’s a cache management solution within email scheduling there are a couple of things you can try.


One thing to consider is using a scripted cron job to make an API call to clear cache before the scheduled email is sent. Doing this will help ensure that the scheduled email runs fresh queries before sending instead of pulling from query cache.


Another thing to experiment with is using the persist_for parameter at either the explore or model level to extend the time queries are allowed to be fetched from cache. Doing this overrides the default cache time of one hour (as of Looker 4.2, from five minutes in previous versions). If you set a persist_for of 24 hours, for instance, queries will be pulled from cache for that period, except when a user selects ‘Clear Cache and Refresh’ when running an explore, look or dashboard which ‘resets’ the cache timer for another 24 hours. That is, setting a 24-hour persist_for won’t automatically hold cache for one day, it will hold queries in cache for 24 hours from the last time the cache was cleared. If users are clearing cache every five minutes, for instance, the cache will persist for five minutes regardless of the persist_for setting.


Persist_for, in combination with API calls to clear cache before sending the scheduled email may do what you need!


Regarding your second post, caching logic is the same for both Dashboards and Looks.


I hope that helps!

Hi,


Is there any way to set the explore to clear cache and refresh at a certain time of day without using an API call?


For example I’d like to set the explore to update at 2 certain times of day then cache in between.


Thanks,


Tom

Userlevel 4
Badge

@twood the only way to do so currently is with the API. We’re currently discussing exposing more granular caching options in the model using LookML.

@Zam any updates on this?

Thanks!

Userlevel 2

Hi @kcee,


Are you trying to bust the cache or set the cache for a schedule?


Cheers,

Vincent

Hey @vincent,


I’m trying to set the cache for a couple scheduled dashboards.


Thanks,


Kesang

Userlevel 2

Hi @kcee,


Right now the best way to do this is to setup a persist_for on the explore or to schedule the dashboard an hour before it goes out since the default cache time is an hour(unless you changed it with a persist for). Let me know if you have any questions or concerns.


Cheers,

Vincent

Is there any update on this for scheduling dashboards? Would prefer not make API calls

Hi @e-rex, As Vincent mentioned above, this is still the recommended workaround for Caching Dashboards With Scheduler.

Is there any update here?

It still seems to be a really painful issue for early morning reports. The thread above says the product team was looking into this 4 years ago.

Userlevel 4

Hi Ryan

i think you can use:


datagroup: dg_ecustomer {

label: “Datagroup Ecustomer”

description: “runs after each etl”

sql_trigger: select max(date) from your job_table;;

max_cache_age: “24 hours”

}


or even better:



Hi Zam,

which API are you referring to? I was not able to find it

Hi @Zam and @dave!

Could you point me to how to execute the "Clear Cache" action through the API. I was not able to find it too…

Userlevel 7
Badge

You have to update the data group and set stale before time to now and/or trigger time

Thanks, @IanT ! Works like a charm!

Reply