mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6862] [MERGED] fix(sub): send no-store on every subscription body #6486
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#6486
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6862
Author: @yukh975
Created: 10/17/2026
Status: ✅ Merged
Merged: 10/24/2026
Merged by: @MHSanaei
Base:
main← Head:fix/sub-no-cache📝 Commits (3)
521491ffix(sub): send no-store on every subscription bodyaf287c9Merge remote-tracking branch 'origin/main' into pr/68623c9f7e1refactor(sub): make no-store a rule of every subscription route group📊 Changes
2 files changed (+35 additions, -11 deletions)
View changed files
📝
internal/sub/controller.go(+7 -11)📝
internal/sub/controller_test.go(+28 -0)📄 Description
What happens
Subscription bodies carry live state — traffic/expiry figures in
Subscription-Userinfo, and the Happ/Incy routing headers (Routing,Routing-Enable,Profile-Update-Interval). Only the HTML page and?format=infobranches callsetNoCacheHeaders:Cache-ControlAccept: text/html)no-cache, no-store, must-revalidate?format=infono-cache, no-store, must-revalidatesubs)serveJsonBody)serveClashBody)With no
Cache-Control,PragmaorExpires, an HTTP cache (client, CDN or reverse proxy) may store and re-serve a subscription for as long as it likes.Reproduction (real case)
domain:example.comfromDirectSitesand adds it toProxySitesin the subscription routing template (subRoutingRules).Routing:header and the JSON body both show the new rule (verified against the panel).This bites hardest with routing changes, because
Routing:is a header: a cached copy silently keeps a stale deeplink alive.Fix
Call
setNoCacheHeaders(c)in the three body-serving paths:subs()— before any branch, which covers the raw base64 body and the auto-detected Clash/JSON branches;serveJsonBody()— covers/json/,?format=jsonand?view=raw;serveClashBody()— covers/clash/,?format=clashand?view=raw.Placed after the empty-body early returns so error/empty responses keep their current behaviour.
Test
TestSubscriptionBodiesAreNotCacheabledrives all seven branches through the real router (raw, auto-detected Clash, auto-detected JSON,/json/,/json/?view=raw,/clash/,/clash/?view=raw) and assertsCache-Controlcontainsno-store.Verified it fails without the fix on every branch:
and passes with it:
go vetclean,gofmtclean, fullgo test ./internal/sub/green.Scope
3 lines of production code + 1 test file. No behaviour change other than the headers; no new knobs.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.