Skip to content

OCPBUGS-70112: Add Cache-Control headers to console responses - #16923

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
jrangelramos:OCPBUGS-70112-cache-control-headers-main
Aug 11, 2026
Merged

OCPBUGS-70112: Add Cache-Control headers to console responses#16923
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
jrangelramos:OCPBUGS-70112-cache-control-headers-main

Conversation

@jrangelramos

@jrangelramos jrangelramos commented Aug 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Set restrictive cache headers (no-cache, no-store, must-revalidate + Pragma: no-cache) by default on all responses via WithSecurityHeaders
  • Override with aggressive caching (public, max-age=31536000, immutable) for content-hashed static assets under /static/ via new WithStaticCacheHeaders
  • Remove redundant inner WithSecurityHeaders wrap on the static handler (the outer mux-level middleware already covers it)

Test plan

  • go build ./cmd/bridge/... compiles cleanly
  • go test ./pkg/middleware/... — 3 new tests pass:
    • TestWithSecurityHeaders — all 6 headers (4 existing + 2 new)
    • TestWithStaticCacheHeaders — static handler overrides restrictive defaults
    • TestNonStaticEndpointHasNoCacheHeaders — API endpoints get no-store
  • Manual: browser DevTools Network tab confirms index.html gets no-store, /static/ bundles get max-age=31536000

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Performance
    • Static assets now use long-lived, immutable caching to improve load times and reduce repeated downloads.
  • Bug Fixes
    • Non-static responses now consistently prevent browser and intermediary caching.
    • Static asset delivery retains compression and directory-listing protection while using optimized caching behavior.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 7, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@jrangelramos: This pull request references Jira Issue OCPBUGS-70112, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Summary

  • Set restrictive cache headers (no-cache, no-store, must-revalidate + Pragma: no-cache) by default on all responses via WithSecurityHeaders
  • Override with aggressive caching (public, max-age=31536000, immutable) for content-hashed static assets under /static/ via new WithStaticCacheHeaders
  • Remove redundant inner WithSecurityHeaders wrap on the static handler (the outer mux-level middleware already covers it)

Test plan

  • go build ./cmd/bridge/... compiles cleanly
  • go test ./pkg/middleware/... — 3 new tests pass:
  • TestWithSecurityHeaders — all 6 headers (4 existing + 2 new)
  • TestWithStaticCacheHeaders — static handler overrides restrictive defaults
  • TestNonStaticEndpointHasNoCacheHeaders — API endpoints get no-store
  • Manual: browser DevTools Network tab confirms index.html gets no-store, /static/ bundles get max-age=31536000

🤖 Generated with Claude Code

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
openshift-ci Bot requested review from Leo6Leo and jhadvig August 7, 2026 13:25
@openshift-ci openshift-ci Bot added the component/backend Related to backend label Aug 7, 2026
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 59d9d39e-b8d5-439e-a2b1-c8dd15870bee

📥 Commits

Reviewing files that changed from the base of the PR and between 6563a5b and 0d8f8c7.

📒 Files selected for processing (1)
  • pkg/middleware/middleware_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/middleware/middleware_test.go

Walkthrough

The middleware adds no-cache headers for non-static responses and immutable public caching for static assets. The /static/ route uses the static cache middleware. Tests cover both behaviors and non-static defaults.

Changes

Cache Header Behavior

Layer / File(s) Summary
Middleware headers and validation
pkg/middleware/middleware.go, pkg/middleware/middleware_test.go
WithSecurityHeaders sets no-cache headers. WithStaticCacheHeaders sets one-year immutable caching and removes Pragma. Tests validate both behaviors and non-static defaults.
Static route cache integration
pkg/server/server.go
The /static/ route uses WithStaticCacheHeaders while retaining gzip encoding and directory-listing protection.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: jhadvig, leo6leo

🚥 Pre-merge checks | ✅ 13 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the main changes and tests, but it omits most required template sections, including root cause, setup, browser conformance, and reviewers. Complete the required template sections, especially Analysis / Root cause, Solution description, Test setup, Browser conformance, Additional info, and Reviewers and assignees.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (13 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the Jira issue and the primary change: adding cache-control headers to console responses.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The added tests use stable Go names: TestWithSecurityHeaders, TestWithStaticCacheHeaders, and TestNonStaticEndpointHasNoCacheHeaders. No Ginkgo title declarations were added.
Test Structure And Quality ✅ Passed Not applicable: the changed tests use Go's standard testing package with Test functions, not Ginkgo It blocks; no cluster resources or Eventually/Consistently waits are present.
Microshift Test Compatibility ✅ Passed The PR adds only standard Go unit tests using testing.T; it adds no Ginkgo e2e tests, so MicroShift API compatibility checks are not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The added tests are standard Go testing functions (TestWith...), not Ginkgo e2e tests, and contain no multi-node or HA assumptions to assess.
Topology-Aware Scheduling Compatibility ✅ Passed The commit changes only HTTP middleware, tests, and static-handler wiring; it adds no deployment, controller, manifest, replica, affinity, taint, or node-selection scheduling constraints.
Ote Binary Stdout Contract ✅ Passed The PR adds only HTTP middleware and ordinary unit tests; no OTE binary, suite setup, or process-level stdout write is introduced.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The PR adds only standard Go Test functions using httptest; no new Ginkgo e2e tests, IPv4 assumptions, or external network calls are present.
No-Weak-Crypto ✅ Passed The PR only adds HTTP cache-header middleware/tests and changes static-handler composition; it introduces no weak crypto or secret/token comparison.
Container-Privileges ✅ Passed The PR changes only Go files and adds no privileged container or Kubernetes settings; the runtime Dockerfile stage uses USER 1001, while USER 0 is limited to an existing build stage.
No-Sensitive-Data-In-Logs ✅ Passed The patch adds no logging. Added code and tests contain no passwords, tokens, keys, PII, hostnames, or customer data.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jrangelramos

Copy link
Copy Markdown
Member Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 7, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@jrangelramos: This pull request references Jira Issue OCPBUGS-70112, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira (yapei@redhat.com), skipping review request.

Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@jrangelramos: This pull request references Jira Issue OCPBUGS-70112, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira (yapei@redhat.com), skipping review request.

Details

In response to this:

Summary

  • Set restrictive cache headers (no-cache, no-store, must-revalidate + Pragma: no-cache) by default on all responses via WithSecurityHeaders
  • Override with aggressive caching (public, max-age=31536000, immutable) for content-hashed static assets under /static/ via new WithStaticCacheHeaders
  • Remove redundant inner WithSecurityHeaders wrap on the static handler (the outer mux-level middleware already covers it)

Test plan

  • go build ./cmd/bridge/... compiles cleanly
  • go test ./pkg/middleware/... — 3 new tests pass:
  • TestWithSecurityHeaders — all 6 headers (4 existing + 2 new)
  • TestWithStaticCacheHeaders — static handler overrides restrictive defaults
  • TestNonStaticEndpointHasNoCacheHeaders — API endpoints get no-store
  • Manual: browser DevTools Network tab confirms index.html gets no-store, /static/ bundles get max-age=31536000

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Performance
  • Static assets now use long-lived, immutable caching to improve load times and reduce repeated downloads.
  • Bug Fixes
  • Non-static responses now consistently prevent browser and intermediary caching.
  • Static asset delivery retains compression and directory-listing protection while using optimized caching behavior.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@jrangelramos

Copy link
Copy Markdown
Member Author

manual verification

$ curl -skI $CONSOLE_URL | grep -iE 'cache-control|pragma|expires'  
cache-control: no-cache, no-store, must-revalidate
pragma: no-cache
$ curl -skI $CONSOLE_URL/static/main-bundle-135c35ac6fc8bd54.min.js | grep -iE 'cache-control|pragma|expires' 
cache-control: public, max-age=31536000, immutable
cache-control: private
$ curl -skI $CONSOLE_URL/api/console/version | grep -iE 'cache-control|pragma|expires'                       
cache-control: no-cache, no-store, must-revalidate
pragma: no-cache
$ echo $CONSOLE_URL    
https://console-openshift-console.apps.jeramos-1333.ci-psi.rhocf-dev.net

@jrangelramos

Copy link
Copy Markdown
Member Author

/verified by Jefferson Ramos

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Aug 7, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@jrangelramos: This PR has been marked as verified by Jefferson Ramos.

Details

In response to this:

/verified by Jefferson Ramos

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@jhadvig

jhadvig commented Aug 8, 2026

Copy link
Copy Markdown
Member

/retest

Set restrictive cache headers (no-cache, no-store) by default on all
responses via WithSecurityHeaders, and override with aggressive caching
(public, max-age=31536000, immutable) for content-hashed static assets
under /static/.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jrangelramos
jrangelramos force-pushed the OCPBUGS-70112-cache-control-headers-main branch from 6563a5b to 0d8f8c7 Compare August 10, 2026 19:04
@openshift-ci-robot openshift-ci-robot removed the verified Signifies that the PR passed pre-merge verification criteria label Aug 10, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@jrangelramos: This pull request references Jira Issue OCPBUGS-70112, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira (yapei@redhat.com), skipping review request.

Details

In response to this:

Summary

  • Set restrictive cache headers (no-cache, no-store, must-revalidate + Pragma: no-cache) by default on all responses via WithSecurityHeaders
  • Override with aggressive caching (public, max-age=31536000, immutable) for content-hashed static assets under /static/ via new WithStaticCacheHeaders
  • Remove redundant inner WithSecurityHeaders wrap on the static handler (the outer mux-level middleware already covers it)

Test plan

  • go build ./cmd/bridge/... compiles cleanly
  • go test ./pkg/middleware/... — 3 new tests pass:
  • TestWithSecurityHeaders — all 6 headers (4 existing + 2 new)
  • TestWithStaticCacheHeaders — static handler overrides restrictive defaults
  • TestNonStaticEndpointHasNoCacheHeaders — API endpoints get no-store
  • Manual: browser DevTools Network tab confirms index.html gets no-store, /static/ bundles get max-age=31536000

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Performance
  • Static assets now use long-lived, immutable caching to improve load times and reduce repeated downloads.
  • Bug Fixes
  • Non-static responses now consistently prevent browser and intermediary caching.
  • Static asset delivery retains compression and directory-listing protection while using optimized caching behavior.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@jrangelramos

Copy link
Copy Markdown
Member Author

/verified by Jefferson Ramos

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Aug 10, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@jrangelramos: This PR has been marked as verified by Jefferson Ramos.

Details

In response to this:

/verified by Jefferson Ramos

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@jhadvig

jhadvig commented Aug 11, 2026

Copy link
Copy Markdown
Member

@jrangelramos verified the cache headers on a live cluster (launch 5.0,openshift/console#16923 gcp).

Test: curl -sk -D - against the console route, checking Cache-Control, Pragma, and security headers on static vs non-static responses.

Endpoint Cache-Control Pragma Security headers
/ (index.html) no-cache, no-store, must-revalidate no-cache all 4 present
/static/*.min.js public, max-age=31536000, immutable absent all 4 present
/static/*.css public, max-age=31536000, immutable absent all 4 present
/static/*.png public, max-age=31536000, immutable absent all 4 present
/api/console/version no-cache, no-store, must-revalidate no-cache all 4 present

One note.... the OpenShift router (HAProxy) appends a second cache-control: private to static asset responses because they carry a Set-Cookie header from the router's session affinity. This is standard HAProxy behavior, not a code issue, and doesn't affect browser-side caching (max-age + immutable still work).

LGTM 👍

/lgtm
/verified by @jhadvig

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@jhadvig: This PR has been marked as verified by @jhadvig.

Details

In response to this:

@jrangelramos verified the cache headers on a live cluster (launch 5.0,openshift/console#16923 gcp).

Test: curl -sk -D - against the console route, checking Cache-Control, Pragma, and security headers on static vs non-static responses.

Endpoint Cache-Control Pragma Security headers
/ (index.html) no-cache, no-store, must-revalidate no-cache all 4 present
/static/*.min.js public, max-age=31536000, immutable absent all 4 present
/static/*.css public, max-age=31536000, immutable absent all 4 present
/static/*.png public, max-age=31536000, immutable absent all 4 present
/api/console/version no-cache, no-store, must-revalidate no-cache all 4 present

One note.... the OpenShift router (HAProxy) appends a second cache-control: private to static asset responses because they carry a Set-Cookie header from the router's session affinity. This is standard HAProxy behavior, not a code issue, and doesn't affect browser-side caching (max-age + immutable still work).

LGTM 👍

/lgtm
/verified by @jhadvig

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 11, 2026
@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jhadvig, jrangelramos

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-gcp-console
/test e2e-playwright

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 11, 2026
@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

@jrangelramos: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot
openshift-merge-bot Bot merged commit 5af26da into openshift:main Aug 11, 2026
11 checks passed
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@jrangelramos: Jira Issue OCPBUGS-70112: Some pull requests linked via external trackers have merged:

The following pull request, linked via external tracker, has not merged:

All associated pull requests must be merged or unlinked from the Jira bug in order for it to move to the next state. Once unlinked, request a bug refresh with /jira refresh.

Jira Issue OCPBUGS-70112 has not been moved to the MODIFIED state.

This PR is marked as verified. If the remaining PRs listed above are marked as verified before merging, the issue will automatically be moved to VERIFIED after all of the changes from the PRs are available in an accepted nightly payload.

Details

In response to this:

Summary

  • Set restrictive cache headers (no-cache, no-store, must-revalidate + Pragma: no-cache) by default on all responses via WithSecurityHeaders
  • Override with aggressive caching (public, max-age=31536000, immutable) for content-hashed static assets under /static/ via new WithStaticCacheHeaders
  • Remove redundant inner WithSecurityHeaders wrap on the static handler (the outer mux-level middleware already covers it)

Test plan

  • go build ./cmd/bridge/... compiles cleanly
  • go test ./pkg/middleware/... — 3 new tests pass:
  • TestWithSecurityHeaders — all 6 headers (4 existing + 2 new)
  • TestWithStaticCacheHeaders — static handler overrides restrictive defaults
  • TestNonStaticEndpointHasNoCacheHeaders — API endpoints get no-store
  • Manual: browser DevTools Network tab confirms index.html gets no-store, /static/ bundles get max-age=31536000

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Performance
  • Static assets now use long-lived, immutable caching to improve load times and reduce repeated downloads.
  • Bug Fixes
  • Non-static responses now consistently prevent browser and intermediary caching.
  • Static asset delivery retains compression and directory-listing protection while using optimized caching behavior.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@jrangelramos

Copy link
Copy Markdown
Member Author

/cherry-pick release-4.23
/cherry-pick release-4.22
/cherry-pick release-4.21

@openshift-cherrypick-robot

Copy link
Copy Markdown

@jrangelramos: new pull request created: #16959

Details

In response to this:

/cherry-pick release-4.23
/cherry-pick release-4.22
/cherry-pick release-4.21

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-cherrypick-robot

Copy link
Copy Markdown

@jrangelramos: new pull request created: #16960

Details

In response to this:

/cherry-pick release-4.23
/cherry-pick release-4.22
/cherry-pick release-4.21

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-cherrypick-robot

Copy link
Copy Markdown

@jrangelramos: new pull request could not be created: failed to create pull request against openshift/console#release-4.23 from head openshift-cherrypick-robot:cherry-pick-16923-to-release-4.23: status code 422 not one of [201], body: {"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"No commits between openshift:release-4.23 and openshift-cherrypick-robot:cherry-pick-16923-to-release-4.23"}],"documentation_url":"https://docs.github.com/rest/pulls/pulls#create-a-pull-request","status":"422"}

Details

In response to this:

/cherry-pick release-4.23
/cherry-pick release-4.22
/cherry-pick release-4.21

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/backend Related to backend jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants