Apache Artemis管理Jetty控制台。配置缓存控制头
如果我运行Apache Artemis,并通过代理访问管理控制台,然后用新版本重启Artemis(例如从2.52.0升级到2.53.0),浏览器中的React.js管理控制台仍然会运行旧版本的控制台。
默认情况下,cache-control设置为 'no-cache'。我认为cache-control应该是
Cache-Control "no-cache, no-store, must-revalidate"
下面是一个docker-compose用来说明这个设置。
compose.yml
version: '3.8'
services:
artemis:
image: apache/artemis:2.53.0
ports:
- "8161:8161" # Web console (console0/console1)
- "61616:61616" # OpenWire
expose:
- "61616"
- "8161"
haproxy:
image: haproxy:2.9-alpine
ports:
- "8080:8080" # HAProxy frontend
volumes:
- ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
# Run as root to avoid any log permission issues (safe for dev)
user: root
restart: unless-stopped
haproxy.cfg
global
log stdout format raw local0 info # Stdout logging = no permission denied!
daemon
defaults
log global
mode http
frontend artemis-console
bind *:8080
default_backend artemis-backend
backend artemis-backend
option forwardfor
http-reuse safe
server artemis artemis:8161 check inter 2s rise 2 fall 3
运行
docker compose up
访问管理控制台 http://localhost:8080/console/artemis(默认用户名/密码artemis:artemis)
点击About。你应该看到版本为2.53
现在只需重启Artemis,并把镜像版本改为2.52,然后重新启动Artemis。
访问管理控制台并点击About。结果是版本仍然是2.53。
我可以通过代理中的设置来修复这个问题:
frontend artemis-console
bind *:8080
default_backend artemis-backend
# Cache busting headers for React apps
http-response set-header Cache-Control "no-cache, no-store, must-revalidate"
我的问题是,是否可以使用Artemis的配置文件来实现,例如broker.xml或 bootstrap.xml?
解决方案
目前无法配置Apache Artemis内嵌的Web服务器返回的 Cache-Control 头字段的值。
就此而言,我认为使用 no-cache, no-store, must-revalidate 过于激进。大多数情况下,缓存是有帮助的。完全禁用它只在极少数特定用例中才有好处。
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。