nex_animation/backend/tests
mula.liu cbc645c4e1 perf(交付面): 按 media type 压缩 + 哈希产物长期缓存,后端与 nginx 同一套口径
Bundle 那十几轮量的是**文件字节**(`chunkinfo`),但线上真正过网的是这一层的响应头:
首屏闭包 1 469 kB 里 1 144 kB 是一个带哈希的 JS chunk,不压就是按 raw 发,量好的
gzip 450 kB 白量。补上缺的另一半(阶段 29、30)。

backend/app/main.py:
- `gzip_eligible()` 是唯一的权威名单,只认 media type 不认路径前缀(只压文本,
  mp4 与已压过的图片挡在外面);`ContentTypeGZipMiddleware` 按它决定是否压,
  小于阈值的响应不压(压完加头比原文还大,还多一个 `Vary` 命中率)。
- 中间件顺序是有条件的:压缩层必须**最先**注册,否则 `add_middleware` 把自己插到
  最外层之后,压缩跑到了鉴权外面。
- 交付面缓存:`/assets` 带内容哈希 ⇒ `public, max-age=31536000, immutable`;
  `index.html` 与 history 回落出去的壳 ⇒ `no-cache` 每次回源校验,否则发版后老标签页
  拿着旧壳去引已经不存在的哈希文件,用户看到白屏。

frontend/nginx.conf:反代这一层写同一套口径(注释里点名「权威名单在后端
`app.main.gzip_eligible`,这里这份是兜底」),并补 `gzip_proxied any`——
它管的是**带 `Via` 请求头的请求**(nginx 站在 CDN 后面时),默认 `off` 下直连浏览器
照样压;挂 CDN 时这套压缩不能整块失效。三组合 A/B/C 的实测对账在
`reports/ui_evidence/nex-p30/nginx-ab.log`:后端已压时 nginx 透传不叠第二层,
后端没压时这里兜底压上(A 组合 `/api/projects` 341 909 → 53 333 B 是 nginx 自己压的)。

测试:新增 `backend/tests/test_api_content_gzip.py`,`test_spa_history_fallback.py`
补 `test_asset_delivery_cache_and_gzip`,三条断言各自钉住一个会真实发生的事故
(不压 / 壳不回源 / 小文件也压)。
2026-11-12 10:21:17 +08:00
..
conftest.py v 0.1.2 2026-11-07 00:48:17 +08:00
test_agent_inflight_wait.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_agent_orchestrator.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_agent_qc_rework.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_api_content_gzip.py perf(交付面): 按 media type 压缩 + 哈希产物长期缓存,后端与 nginx 同一套口径 2026-11-12 10:21:17 +08:00
test_asset_version_management.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_auth.py fix(配置): 初始管理员口令三处对齐到 admin@123,测试不再抄第二遍口令 2026-11-12 10:21:03 +08:00
test_comfyui_adapter.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_compose_transition_timebase.py v 0.1.2 2026-11-07 13:03:58 +08:00
test_config_dotenv.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_db_pool.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_delivery.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_direct_connection.py v 0.1.2 2026-11-07 00:48:17 +08:00
test_drain_stalled.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_generation_pipeline.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_identity_source_of_truth.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_import_storyboard.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_index_tts_instruct.py v 0.1.1 2026-11-05 16:53:24 +08:00
test_joint_caption.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_keyframe_freshness.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_loudnorm_two_pass.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_multi_view_reference_clone.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_platform_assets.py v 0.1.2 2026-11-07 00:48:17 +08:00
test_platform_library_v2.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_platform_schema_columns.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_platform_version_reuse.py v 0.1.2 2026-11-07 00:48:17 +08:00
test_provider_outage.py 前端四项调整:输入框去掉光晕、账号菜单收口、逐页删开发期说明书、登录页重做成左右分栏 2026-11-05 22:09:16 +08:00
test_qc_verdict_reuse.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_reference_authority.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_regeneration_intent.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_regression_fixes.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_retry_resume.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_run_reconciliation.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_shot_preview.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_spa_history_fallback.py perf(交付面): 按 media type 压缩 + 哈希产物长期缓存,后端与 nginx 同一套口径 2026-11-12 10:21:17 +08:00
test_speaker_voice_binding.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_speaking_subject.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_speech_qc.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_startup_lock.py v 0.1.2 2026-11-07 00:48:17 +08:00
test_storyboard_workbench.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_subtitle_modes.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_system_and_library.py 前端四项调整:输入框去掉光晕、账号菜单收口、逐页删开发期说明书、登录页重做成左右分栏 2026-11-05 22:09:16 +08:00
test_task_activity.py v 0.1.2 2026-11-07 00:48:17 +08:00
test_thumbs.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_visual_qc.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_voice_record_upload.py v 0.1.0 2026-11-01 16:18:07 +08:00
test_voice_timbre_gender.py v 0.1.2 2026-11-07 00:48:17 +08:00