mirror of
https://github.com/apache/superset.git
synced 2026-05-22 00:05:15 +00:00
Previously docusaurus.config.ts had `onBrokenLinks: 'warn'`, so broken
internal links produced advisory warnings during build but didn't gate
merges. Tightening to `throw` surfaces every broken internal route at
build time. Three classes of issue fell out:
1. Stale `/docs/...` and `/docs/6.0.0/...` references in the 6.0.0
versioned snapshot. The user-facing docs section was renamed
`docs` → `user-docs` (routeBasePath) at some point after 6.0.0 was
cut, but the snapshot's links still pointed at the old prefix. The
live site redirects /docs/* → /user-docs/* at runtime, but
Docusaurus's onBrokenLinks checker doesn't honor redirects.
Bulk-rewrote /docs/* → /user-docs/* across the snapshot (and one
/docs/api → /developer-docs/api).
2. Bare-relative MDX links like `[Label](./mcp)` (no .md/.mdx
extension). Docusaurus renders an absolute href in SSR HTML, so
static crawlers see correct links — BUT React Router's `<Link>`
component on the client side resolves the bare path relative to
the current URL on click, so when the page URL has a trailing
slash (e.g. /extensions/overview/), `./mcp` becomes
/extensions/overview/mcp (404). This is exactly the broken-flow a
user reported on /developer-docs/extensions/overview/. Added the
`.md`/`.mdx` extension to all 44 such links across 17 files; this
makes Docusaurus resolve them to the canonical doc URL at the
<Link> level, so SPA navigation works regardless of trailing slash.
3. Miscellaneous content fixes:
- 4 `/configuration/feature-flags` references in 6.0.0 snapshot
pointed at a page that doesn't exist in that version (the
dedicated feature-flags page was added later). Repointed to the
`#feature-flags` anchor inside `configuring-superset.mdx`.
- 3 references to `superset-core/src/superset_core/rest_api/decorators.py`
in extensions docs were rendered as relative URLs, resolving to
/developer-docs/extensions/superset-core/... (404). Converted to
absolute GitHub URLs.
- 1 `/storybook/?path=...` link in extensions/components/index.mdx
pointed at a non-existent route. Repointed to the existing
`/developer-docs/testing/storybook` page that explains how to
run Storybook locally.
- 4 unclosed-paren markdown links in 6.0.0 installation-methods.mdx
(pre-existing source bugs).
Build now passes with `onBrokenLinks: 'throw'`. Note that
`onBrokenAnchors` is still `'warn'` (default); a separate effort
should tighten that and fix the surviving anchor warnings (currently
~60 instances of `/community#superset-community-calendar`).
155 lines
5.0 KiB
Plaintext
155 lines
5.0 KiB
Plaintext
---
|
|
title: Caching
|
|
hide_title: true
|
|
sidebar_position: 3
|
|
version: 1
|
|
---
|
|
|
|
# Caching
|
|
|
|
Superset uses [Flask-Caching](https://flask-caching.readthedocs.io/) for caching purposes.
|
|
Flask-Caching supports various caching backends, including Redis (recommended), Memcached,
|
|
SimpleCache (in-memory), or the local filesystem.
|
|
[Custom cache backends](https://flask-caching.readthedocs.io/en/latest/#custom-cache-backends)
|
|
are also supported.
|
|
|
|
Caching can be configured by providing dictionaries in
|
|
`superset_config.py` that comply with [the Flask-Caching config specifications](https://flask-caching.readthedocs.io/en/latest/#configuring-flask-caching).
|
|
|
|
The following cache configurations can be customized in this way:
|
|
|
|
- Dashboard filter state (required): `FILTER_STATE_CACHE_CONFIG`.
|
|
- Explore chart form data (required): `EXPLORE_FORM_DATA_CACHE_CONFIG`
|
|
- Metadata cache (optional): `CACHE_CONFIG`
|
|
- Charting data queried from datasets (optional): `DATA_CACHE_CONFIG`
|
|
|
|
For example, to configure the filter state cache using Redis:
|
|
|
|
```python
|
|
FILTER_STATE_CACHE_CONFIG = {
|
|
'CACHE_TYPE': 'RedisCache',
|
|
'CACHE_DEFAULT_TIMEOUT': 86400,
|
|
'CACHE_KEY_PREFIX': 'superset_filter_cache',
|
|
'CACHE_REDIS_URL': 'redis://localhost:6379/0'
|
|
}
|
|
```
|
|
|
|
## Dependencies
|
|
|
|
In order to use dedicated cache stores, additional python libraries must be installed
|
|
|
|
- For Redis: we recommend the [redis](https://pypi.python.org/pypi/redis) Python package
|
|
- Memcached: we recommend using [pylibmc](https://pypi.org/project/pylibmc/) client library as
|
|
`python-memcached` does not handle storing binary data correctly.
|
|
|
|
These libraries can be installed using pip.
|
|
|
|
## Fallback Metastore Cache
|
|
|
|
Note, that some form of Filter State and Explore caching are required. If either of these caches
|
|
are undefined, Superset falls back to using a built-in cache that stores data in the metadata
|
|
database. While it is recommended to use a dedicated cache, the built-in cache can also be used
|
|
to cache other data.
|
|
|
|
For example, to use the built-in cache to store chart data, use the following config:
|
|
|
|
```python
|
|
DATA_CACHE_CONFIG = {
|
|
"CACHE_TYPE": "SupersetMetastoreCache",
|
|
"CACHE_KEY_PREFIX": "superset_results", # make sure this string is unique to avoid collisions
|
|
"CACHE_DEFAULT_TIMEOUT": 86400, # 60 seconds * 60 minutes * 24 hours
|
|
}
|
|
```
|
|
|
|
## Chart Cache Timeout
|
|
|
|
The cache timeout for charts may be overridden by the settings for an individual chart, dataset, or
|
|
database. Each of these configurations will be checked in order before falling back to the default
|
|
value defined in `DATA_CACHE_CONFIG`.
|
|
|
|
Note, that by setting the cache timeout to `-1`, caching for charting data can be disabled, either
|
|
per chart, dataset or database, or by default if set in `DATA_CACHE_CONFIG`.
|
|
|
|
## SQL Lab Query Results
|
|
|
|
Caching for SQL Lab query results is used when async queries are enabled and is configured using
|
|
`RESULTS_BACKEND`.
|
|
|
|
Note that this configuration does not use a flask-caching dictionary for its configuration, but
|
|
instead requires a cachelib object.
|
|
|
|
See [Async Queries via Celery](/user-docs/6.0.0/configuration/async-queries-celery) for details.
|
|
|
|
## Caching Thumbnails
|
|
|
|
This is an optional feature that can be turned on by activating its [feature flag](/user-docs/6.0.0/configuration/configuring-superset#feature-flags) on config:
|
|
|
|
```
|
|
FEATURE_FLAGS = {
|
|
"THUMBNAILS": True,
|
|
"THUMBNAILS_SQLA_LISTENERS": True,
|
|
}
|
|
```
|
|
|
|
By default thumbnails are rendered per user, and will fall back to the Selenium user for anonymous users.
|
|
To always render thumbnails as a fixed user (`admin` in this example), use the following configuration:
|
|
|
|
```python
|
|
from superset.tasks.types import FixedExecutor
|
|
|
|
THUMBNAIL_EXECUTORS = [FixedExecutor("admin")]
|
|
```
|
|
|
|
For this feature you will need a cache system and celery workers. All thumbnails are stored on cache
|
|
and are processed asynchronously by the workers.
|
|
|
|
An example config where images are stored on S3 could be:
|
|
|
|
```python
|
|
from flask import Flask
|
|
from s3cache.s3cache import S3Cache
|
|
|
|
...
|
|
|
|
class CeleryConfig(object):
|
|
broker_url = "redis://localhost:6379/0"
|
|
imports = (
|
|
"superset.sql_lab",
|
|
"superset.tasks.thumbnails",
|
|
)
|
|
result_backend = "redis://localhost:6379/0"
|
|
worker_prefetch_multiplier = 10
|
|
task_acks_late = True
|
|
|
|
|
|
CELERY_CONFIG = CeleryConfig
|
|
|
|
def init_thumbnail_cache(app: Flask) -> S3Cache:
|
|
return S3Cache("bucket_name", 'thumbs_cache/')
|
|
|
|
|
|
THUMBNAIL_CACHE_CONFIG = init_thumbnail_cache
|
|
```
|
|
|
|
Using the above example cache keys for dashboards will be `superset_thumb__dashboard__{ID}`. You can
|
|
override the base URL for selenium using:
|
|
|
|
```
|
|
WEBDRIVER_BASEURL = "https://superset.company.com"
|
|
```
|
|
|
|
Additional selenium web drive configuration can be set using `WEBDRIVER_CONFIGURATION`. You can
|
|
implement a custom function to authenticate selenium. The default function uses the `flask-login`
|
|
session cookie. Here's an example of a custom function signature:
|
|
|
|
```python
|
|
def auth_driver(driver: WebDriver, user: "User") -> WebDriver:
|
|
pass
|
|
```
|
|
|
|
Then on configuration:
|
|
|
|
```
|
|
WEBDRIVER_AUTH_FUNC = auth_driver
|
|
```
|