GitHub user dosubot[bot] added a comment to the discussion: Cache warm_up logic?
<!-- Answer --> This happens because Superset's cache key for each chart is built from not just the user, but also the full request context—like dashboard filters, ad-hoc filters, URL parameters, and any Jinja macros (such as `current_user_id()`, `url_param()`, etc.) used in your chart SQL. If any of these differ between the warmup API call and your UI dashboard load, the cache key will be different, so the cache won't be hit—even for the same user. After your first UI load, the cache is populated with the exact context of your session, so subsequent loads are fast until something changes in the context again. To avoid repeated queries, make sure your cache warmup task includes all relevant parameters: pass the same `dashboard_id`, `extra_filters`, and any URL params or context that your real dashboard users would have. If your charts use user-specific macros or filters, cache warmup will only help if it exactly matches the context of the real request. You can check the logs for cache key info and compare them between warmup and UI loads to debug mismatches. More details on cache key construction and warmup context are in the code [here](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/viz.py) and [here](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/jinja_context.py). If you want to maximize cache hits, try to simulate the real dashboard context as closely as possible in your warmup calls. If your charts are user-agnostic (no user-specific macros or RLS), a single warmup should suffice for all users. Otherwise, you'll need to warm up for each unique context you care about. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/30fbbb02-7f2d-4df1-ba49-e8115e8eb1cf?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/30fbbb02-7f2d-4df1-ba49-e8115e8eb1cf?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/30fbbb02-7f2d-4df1-ba49-e8115e8eb1cf?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/30fbbb02-7f2d-4df1-ba49-e8115e8eb1cf?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/30fbbb02-7f2d-4df1-ba49-e8115e8eb1cf?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/30fbbb02-7f2d-4df1-ba49-e8115e8eb1cf?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/30fbbb02-7f2d-4df1-ba49-e8115e8eb1cf?feedback_type=other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)& nbsp;[](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/34837) GitHub link: https://github.com/apache/superset/discussions/34837#discussioncomment-14253167 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
