GitHub user dosubot[bot] added a comment to the discussion: getting error 422 
/api/v1/chart/data/qc-a3....

<!-- Answer -->
Superset's async query and caching flow with Celery and Redis does serve cached 
chart data immediately if it's available, while a Celery worker runs the query 
in the background to refresh the cache—this is similar to a "stale while 
revalidate" pattern. However, if there is no cached data (for example, on first 
load or after cache expiry), Superset does not serve stale data while 
refreshing; instead, the client gets a 202 response and must wait for the async 
job to finish before any data is shown 
([source](https://github.com/apache/superset/blob/master/superset/views/core.py)).

There is no built-in or configurable "stale while revalidate" strategy that 
always serves stale data while a refresh is in progress if the cache is empty 
([source](https://github.com/apache/superset/blob/master/docs/docs/configuration/async-queries-celery.mdx)).
 To minimize cache misses and improve user experience, you can pre-warm the 
cache (e.g., via scheduled jobs or API calls), avoid Jinja templating that 
references dashboard filters (which can cause cache key mismatches and 422 
errors), and use virtual datasets for dynamic SQL logic.

If you need more robust "stale while revalidate" behavior, it would require 
custom frontend or backend logic to always show the last known data even during 
cache refreshes. For now, Superset's async/caching mechanism aligns with "stale 
while revalidate" only when cached data is present 
([source](https://github.com/apache/superset/tasks/async_queries.py)).


<!-- 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/4e42561f-add5-4b3e-b815-66079311189b?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/4e42561f-add5-4b3e-b815-66079311189b?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/4e42561f-add5-4b3e-b815-66079311189b?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/4e42561f-add5-4b3e-b815-66079311189b?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/4e42561f-add5-4b3e-b815-66079311189b?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/4e42561f-add5-4b3e-b815-66079311189b?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/4e42561f-add5-4b3e-b815-66079311189b?feedback_type=other)</sup>

[![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=Superset%27s%20async%20query%20and%20caching%20flow%20with%20Celery%20and%20Redis%20does%20serve%20cached%20chart%20data%20immediately%20if%20it%27s%20available%2C%20while%20a%20Celery%20worker%20runs%20the%20query%20in%20the%20background%20to%20refresh%20the%20cache%E2%80%94this%20is%20similar%20to%20a%20%22stale%20while%20revalidate%22%20pattern.%20However%2C%20if%20there%20is%20no%20cached%20data%20%28for%20example%2C%20on%20first%20load%20or%20after%20cache%20expiry%29%2C%20Superset%20does%20not%20serve%20stale%20data%20while%20refreshing%3B%20instead%2C%20the%20client%20gets%20a%20202%20response%20and%20must%20wait%20for%20the%20async%20job%20to%20finish%20before%20any%20data%20is%20shown%C2%A0%28%5Bsource%5D%28https%3A//github.com/apache/superse
 
t/blob/master/superset/views/core.py%29%29.%0A%0AThere%20is%20no%20built-in%20or%20configurable%20%22stale%20while%20revalidate%22%20strategy%20that%20always%20serves%20stale%20data%20while%20a%20refresh%20is%20in%20progress%20if%20the%20cache%20is%20empty%C2%A0%28%5Bsource%5D%28https%3A//github.com/apache/superset/blob/master/docs/docs/configuration/async-queries-celery.mdx%29%29.%20To%20minimize%20cache%20misses%20and%20improve%20user%20experience%2C%20you%20can%20pre-warm%20the%20cache%20%28e.g.%2C%20via%20scheduled%20jobs%20or%20API%20calls%29%2C%20avoid%20Jinja%20templating%20that%20references%20dashboard%20filters%20%28which%20can%20cause%20cache%20key%20mismatches%20and%20422%20errors%29%2C%20and%20use%20virtual%20datasets%20for%20dynamic%20SQL%20logic.%0A%0AIf%20you%20need%20more%20robust%20%22stale%20while%20revalidate%22%20behavior%2C%20it%20would%20require%20custom%20frontend%20or%20backend%20logic%20to%20always%20show%20the%20last%20known%20data%20even%20during%20cache%2
 
0refreshes.%20For%20now%2C%20Superset%27s%20async/caching%20mechanism%20aligns%20with%20%22stale%20while%20revalidate%22%20only%20when%20cached%20data%20is%20present%C2%A0%28%5Bsource%5D%28https%3A//github.com/apache/superset/tasks/async_queries.py%29%29.)&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/37306)

GitHub link: 
https://github.com/apache/superset/discussions/37306#discussioncomment-15560718

----
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]

Reply via email to