[GH-ISSUE #17382] feat: Path-based Cache-Control Headers for Mixed Content Types #18261

Closed
opened 2026-04-20 00:27:53 -05:00 by GiteaMirror · 10 comments
Owner

Originally created by @calebhansard on GitHub (Sep 11, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/17382

Check Existing Issues

  • I have searched the existing issues and discussions.

Problem Description

When the CACHE_CONTROL environment variable is set, both static assets and dynamic content share the same cache policy. This causes dynamic workspace content (models, knowledge files, prompts) to become stale until the browser cache expires. While caching significantly improves performance, the inability to see real-time updates without manually clearing cache makes this feature impractical for production use.

Desired Solution you'd like

Implement path-based or content-type-based Cache-Control configuration:

  1. Static assets (JS, CSS, images): Cache-Control: public, max-age=31536000, immutable
  2. Dynamic API responses: Cache-Control: no-cache, must-revalidate
  3. HTML pages: Cache-Control: private, no-cache, must-revalidate

Alternatives Considered

No response

Additional Context

Cache-Control header

Originally created by @calebhansard on GitHub (Sep 11, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/17382 ### Check Existing Issues - [x] I have searched the existing issues and discussions. ### Problem Description When the `CACHE_CONTROL` environment variable is set, both static assets and dynamic content share the same cache policy. This causes dynamic workspace content (models, knowledge files, prompts) to become stale until the browser cache expires. While caching significantly improves performance, the inability to see real-time updates without manually clearing cache makes this feature impractical for production use. ### Desired Solution you'd like Implement path-based or content-type-based Cache-Control configuration: 1. Static assets (JS, CSS, images): `Cache-Control: public, max-age=31536000, immutable` 2. Dynamic API responses: `Cache-Control: no-cache, must-revalidate` 3. HTML pages: `Cache-Control: private, no-cache, must-revalidate` ### Alternatives Considered _No response_ ### Additional Context [Cache-Control header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control)
Author
Owner

@decent-engineer-decent-datascientist commented on GitHub (Sep 17, 2025):

I have to agree with this. While cache does increase the performance by an incredible margin, it also caches stuff that it just shouldn't. For example if I delete a folder with cache enabled, the delete occurs and is reflected in the DB, but the front end does not mirror this (because the call to get folders is cached)

Either through more granular control or just exclusions, this does need to be looked at. The current cache_control approach breaks the front end.

<!-- gh-comment-id:3303813285 --> @decent-engineer-decent-datascientist commented on GitHub (Sep 17, 2025): I have to agree with this. While cache does increase the performance by an incredible margin, it also caches stuff that it just shouldn't. For example if I delete a folder with cache enabled, the delete occurs and is reflected in the DB, but the front end does not mirror this (because the call to get folders is cached) Either through more granular control or just exclusions, this does need to be looked at. The current cache_control approach breaks the front end.
Author
Owner

@joni-graham commented on GitHub (Sep 23, 2025):

Agree that this is an important enhancement to allow caching to be an effective tool for scaling.

<!-- gh-comment-id:3325664786 --> @joni-graham commented on GitHub (Sep 23, 2025): Agree that this is an important enhancement to allow caching to be an effective tool for scaling.
Author
Owner

@Stchizen commented on GitHub (Sep 23, 2025):

This would benefit our deployment as well.

<!-- gh-comment-id:3325678944 --> @Stchizen commented on GitHub (Sep 23, 2025): This would benefit our deployment as well.
Author
Owner

@swiftdev29 commented on GitHub (Oct 21, 2025):

+1
It improves performance significantly, but some very basic functionality is sacrificed. The loading of the model page can definitely be cached but the sidebar with chats shouldn't be. Is there any update/PR for this?

<!-- gh-comment-id:3429563050 --> @swiftdev29 commented on GitHub (Oct 21, 2025): +1 It improves performance significantly, but some very basic functionality is sacrificed. The loading of the model page can definitely be cached but the sidebar with chats shouldn't be. Is there any update/PR for this?
Author
Owner

@pm-priyeshpotdar commented on GitHub (Oct 28, 2025):

+1

<!-- gh-comment-id:3454878874 --> @pm-priyeshpotdar commented on GitHub (Oct 28, 2025): +1
Author
Owner

@rozatoo commented on GitHub (Dec 16, 2025):

+1

<!-- gh-comment-id:3661449016 --> @rozatoo commented on GitHub (Dec 16, 2025): +1
Author
Owner

@Classic298 commented on GitHub (Dec 21, 2025):

updated the docs around this a while ago so it is handled on NGINX end with an example. is this still needed to be handled on open webui end?

<!-- gh-comment-id:3678770284 --> @Classic298 commented on GitHub (Dec 21, 2025): updated the docs around this a while ago so it is handled on NGINX end with an example. is this still needed to be handled on open webui end?
Author
Owner

@kirkegaardk commented on GitHub (Jan 22, 2026):

updated the docs around this a while ago so it is handled on NGINX end with an example. is this still needed to be handled on open webui end?

Do you see any benefits having it within the application itself? The original PR appears more security related than performance, which may have put this consideration out of scope and could explain it's a broad cache application. It seems reasonable to have this at an ingress level and outside the application itself, but honestly am learning as I read. Hence my question here.

Unfortunately NGINX Ingress is retiring and we're looking at Gateway API, which appears not to natively support HTTP caching. However, Varnish does and is something I an looking into as well. Not sure if anyone has worked with that before, but it appears to fit the bill for page caching with more granular controls.

<!-- gh-comment-id:3787060561 --> @kirkegaardk commented on GitHub (Jan 22, 2026): > updated the docs around this a while ago so it is handled on NGINX end with an example. is this still needed to be handled on open webui end? Do you see any benefits having it within the application itself? The original [PR](https://github.com/open-webui/open-webui/pull/5466) appears more security related than performance, which may have put this consideration out of scope and could explain it's a broad cache application. It seems reasonable to have this at an ingress level and outside the application itself, but honestly am learning as I read. Hence my question here. Unfortunately NGINX Ingress is retiring and we're looking at Gateway API, which appears not to natively support HTTP caching. However, Varnish does and is something I an looking into as well. Not sure if anyone has worked with that before, but it appears to fit the bill for page caching with more granular controls.
Author
Owner

@Classic298 commented on GitHub (Jan 22, 2026):

@kirkegaardk

Do you see any benefits having it within the application itself?

Honestly, not really.

By having multiple different env vars or complex JSON structures and having to modify 100s of files to correctly apply the caching everywhere - that's a TON of work for something that can be done with 40 lines of nginx config by just setting js, html, css, images, etc. separately and done

<!-- gh-comment-id:3787066422 --> @Classic298 commented on GitHub (Jan 22, 2026): @kirkegaardk > Do you see any benefits having it within the application itself? Honestly, not really. By having multiple different env vars or complex JSON structures and having to modify 100s of files to correctly apply the caching everywhere - that's a TON of work for something that can be done with 40 lines of nginx config by just setting js, html, css, images, etc. separately and done
Author
Owner

@Classic298 commented on GitHub (Jan 22, 2026):

Yeah thinking about this again; adding multiple different cache control env vars or other means of configuration (which is excessive to have multiple different env vars or one big one with a json object or something that then gets parsed) and correctly apply all the different configs across all relevant files and endpoints is A LOT of work and needs a lot of testing too - and I can already see many users complain about assets being cached (many do not want caching at all for personal deployments or dev setups).

Also - you can really achieve the same result with NGINX and some simple config there.

You can get very very good results by just creating a few location blocks for different file types and endpoints and ... Open WebUI does not have to introduce new config options for this.

Should serve everyone

<!-- gh-comment-id:3787076202 --> @Classic298 commented on GitHub (Jan 22, 2026): Yeah thinking about this again; adding multiple different cache control env vars or other means of configuration (which is excessive to have multiple different env vars or one big one with a json object or something that then gets parsed) and correctly apply all the different configs across all relevant files and endpoints is A LOT of work and needs a lot of testing too - and I can already see many users complain about assets being cached (many do not want caching at all for personal deployments or dev setups). Also - you can really achieve the same result with NGINX and some simple config there. You can get very very good results by just creating a few location blocks for different file types and endpoints and ... Open WebUI does not have to introduce new config options for this. Should serve everyone
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#18261