Skip to content

feat(amber): set cache-control headers for static frontend assets#5846

Open
Ma77Ball wants to merge 13 commits into
apache:mainfrom
Ma77Ball:feat/static-asset-cache-headers
Open

feat(amber): set cache-control headers for static frontend assets#5846
Ma77Ball wants to merge 13 commits into
apache:mainfrom
Ma77Ball:feat/static-asset-cache-headers

Conversation

@Ma77Ball

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

  • Add StaticAssetCacheFilter, registered on /* in TexeraWebApplication, that sets Cache-Control on static frontend responses by request path.
  • index.html, the root, and Angular route paths get no-cache, must-revalidate so a stale entry document is never served past a deploy; content-hashed bundles (name..js/.css and other fingerprinted assets) get public, max-age=31536000, immutable; /api/* responses are left untouched.
  • The Cache-Control decision lives in a pure StaticAssetCacheFilter.cacheControlFor(path) function so it is unit-testable without a servlet container.

Any related issues, documentation, discussions?

Closes: #5835

How was this PR tested?

  • Run sbt "WorkflowExecutionService/testOnly *StaticAssetCacheFilterSpec" on JDK 17, expect 7 passing cases: hashed js/css/media to immutable, index.html and Angular routes to revalidate, /api/* untouched, and short numeric segments not mistaken for a content hash.
  • Manual: build the frontend, start dashboard-service, run curl -I http://localhost:8080/index.html and expect Cache-Control: no-cache, must-revalidate; curl -I a hashed bundle (e.g. /main..js) and expect Cache-Control: public, max-age=31536000, immutable.
  • The servlet registration in TexeraWebApplication.run is covered by the manual curl steps, not the unit spec (the spec covers the header-decision logic).

Was this PR authored or co-authored using generative AI tooling?

Co-authored with Claude Opus 4.8 in compliance with ASF

@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

🟢 6 better · 🔴 3 worse · ⚪ 6 noise (<±5%) · 0 without baseline

Compared against main 6db0d6b benchmarked on this same runner, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.

Dashboard · Run

config throughput MB/s latency max Δ latest / 7d
🔴 bs=10 sw=10 sl=64 410 0.25 23,737/30,798/30,798 us 🔴 -7.1% / 🔴 +97.7%
🟢 bs=100 sw=10 sl=64 838 0.511 119,037/130,878/130,878 us 🟢 -19.2% / 🔴 +19.4%
bs=1000 sw=10 sl=64 929 0.567 1,077,839/1,104,452/1,104,452 us ⚪ within ±5% / 🔴 -6.8%
Baseline details

Latest main 6db0d6b from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 410 tuples/sec 441 tuples/sec 758.88 tuples/sec -7.0% -46.0%
bs=10 sw=10 sl=64 MB/s 0.25 MB/s 0.269 MB/s 0.463 MB/s -7.1% -46.0%
bs=10 sw=10 sl=64 p50 23,737 us 22,385 us 12,965 us +6.0% +83.1%
bs=10 sw=10 sl=64 p95 30,798 us 32,557 us 15,578 us -5.4% +97.7%
bs=10 sw=10 sl=64 p99 30,798 us 32,557 us 18,378 us -5.4% +67.6%
bs=100 sw=10 sl=64 throughput 838 tuples/sec 789 tuples/sec 968.9 tuples/sec +6.2% -13.5%
bs=100 sw=10 sl=64 MB/s 0.511 MB/s 0.482 MB/s 0.591 MB/s +6.0% -13.6%
bs=100 sw=10 sl=64 p50 119,037 us 120,352 us 102,767 us -1.1% +15.8%
bs=100 sw=10 sl=64 p95 130,878 us 162,019 us 109,629 us -19.2% +19.4%
bs=100 sw=10 sl=64 p99 130,878 us 162,019 us 118,129 us -19.2% +10.8%
bs=1000 sw=10 sl=64 throughput 929 tuples/sec 936 tuples/sec 997.01 tuples/sec -0.7% -6.8%
bs=1000 sw=10 sl=64 MB/s 0.567 MB/s 0.571 MB/s 0.609 MB/s -0.7% -6.8%
bs=1000 sw=10 sl=64 p50 1,077,839 us 1,066,572 us 1,009,306 us +1.1% +6.8%
bs=1000 sw=10 sl=64 p95 1,104,452 us 1,103,494 us 1,051,088 us +0.1% +5.1%
bs=1000 sw=10 sl=64 p99 1,104,452 us 1,103,494 us 1,082,535 us +0.1% +2.0%
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,487.59,200,128000,410,0.250,23736.75,30798.38,30798.38
1,100,10,64,20,2387.50,2000,1280000,838,0.511,119037.10,130877.69,130877.69
2,1000,10,64,20,21536.23,20000,12800000,929,0.567,1077838.59,1104452.44,1104452.44

@codecov-commenter

codecov-commenter commented Jun 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.91304% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.17%. Comparing base (6db0d6b) to head (390791f).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...a/org/apache/texera/web/TexeraWebApplication.scala 0.00% 4 Missing ⚠️
...org/apache/texera/web/StaticAssetCacheFilter.scala 89.47% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5846      +/-   ##
============================================
- Coverage     55.19%   55.17%   -0.02%     
+ Complexity     2978     2976       -2     
============================================
  Files          1117     1118       +1     
  Lines         43195    43218      +23     
  Branches       4657     4661       +4     
============================================
+ Hits          23840    23847       +7     
- Misses        17955    17964       +9     
- Partials       1400     1407       +7     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 6db0d6b
agent-service 34.36% <ø> (ø) Carriedforward from 6db0d6b
amber 57.62% <73.91%> (-0.04%) ⬇️
computing-unit-managing-service 0.00% <ø> (ø) Carriedforward from 6db0d6b
config-service 51.56% <ø> (ø) Carriedforward from 6db0d6b
file-service 59.02% <ø> (ø) Carriedforward from 6db0d6b
frontend 48.77% <ø> (ø) Carriedforward from 6db0d6b
notebook-migration-service 78.57% <ø> (ø) Carriedforward from 6db0d6b
pyamber 90.20% <ø> (ø) Carriedforward from 6db0d6b
python 90.76% <ø> (ø) Carriedforward from 6db0d6b
workflow-compiling-service 55.14% <ø> (ø) Carriedforward from 6db0d6b

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Ma77Ball Ma77Ball marked this pull request as ready for review June 21, 2026 07:28
@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @aicam
    You can notify them by mentioning @aicam in a comment.

@Ma77Ball

Copy link
Copy Markdown
Contributor Author

/request-review @Yicong-Huang

@github-actions github-actions Bot requested a review from Yicong-Huang June 22, 2026 18:44
@Ma77Ball

Copy link
Copy Markdown
Contributor Author

/request-review @aglinxinyuan

@github-actions github-actions Bot requested a review from aglinxinyuan June 27, 2026 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set cache headers for index.html and hashed assets to prevent stale-bundle loads

2 participants