Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

perf(warehouse_sources): speed up the new-source catalog page (#73526)

Daniel RC23180e9e0bf8
diff --git a/products/data_warehouse/frontend/shared/components/SourceIcon.tsx b/products/data_warehouse/frontend/shared/components/SourceIcon.tsx
index 15e931ead2c4..55dae0b027a8 100644
--- a/products/data_warehouse/frontend/shared/components/SourceIcon.tsx
+++ b/products/data_warehouse/frontend/shared/components/SourceIcon.tsx
@@ -70,6 +70,11 @@ function SourceIconImage({ src, alt, sizePx }: { src: string; alt: string; sizeP
alt={alt}
height={sizePx}
width={sizePx}
+ // The catalog renders every source's icon at once (1000+ tiles). Without lazy loading the
+ // browser eagerly requests all of them on mount, flooding the network and delaying paint —
+ // only the icons scrolled into view need to load.
+ loading="lazy"
+ decoding="async"
className="object-contain max-w-none rounded"
onError={(e) => {
const img = e.currentTarget
diff --git a/products/warehouse_sources/backend/presentation/views/external_data_source.py b/products/warehouse_sources/backend/presentation/views/external_data_source.py
index 39b7d9b48062..5e9ad526b7e6 100644
--- a/products/warehouse_sources/backend/presentation/views/external_data_source.py
+++ b/products/warehouse_sources/backend/presentation/views/external_data_source.py
@@ -13,6 +13,7 @@ from django.core.exceptions import ValidationError as DjangoValidationError
from django.db import connection, transaction
from django.db.models import Prefetch, Q
from django.utils import timezone
+from django.utils.cache import patch_cache_control
import structlog
import temporalio
@@ -4356,7 +4357,13 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixi
)
configs = {st: config for st, config in configs.items() if st in requested_types}
- return Response(status=status.HTTP_200_OK, data=configs)
+ response = Response(status=status.HTTP_200_OK, data=configs)
+ # The catalog is deploy-static and identical for every user (no team/user input), so let the
+ # browser reuse it across navigations instead of re-downloading and re-parsing several hundred
+ # KB on each visit to the new-source page. `private` because the route is auth-gated; a new
+ # source ships at most once per deploy, so a short freshness window is safe.
+ patch_cache_control(response, private=True, max_age=600)
+ return response
@extend_schema(
parameters=[
diff --git a/products/warehouse_sources/backend/tests/api/test_external_data_source.py b/products/warehouse_sources/backend/tests/api/test_external_data_source.py
index 5df60873bc8a..1f0f800e485c 100644
--- a/products/warehouse_sources/backend/tests/api/test_external_data_source.py
+++ b/products/warehouse_sources/backend/tests/api/test_external_data_source.py
@@ -7832,6 +7832,10 @@ class TestExternalDataSource(APIBaseTest):
payload = response.json()
assert response.status_code == 200
assert payload is not None
+ # The deploy-static catalog is browser-cacheable so repeat visits skip re-downloading it.
+ directives = response.headers["Cache-Control"].split(", ")
+ assert "private" in directives
+ assert "max-age=600" in directives
@parameterized.expand(
[