如何在Wildfly上禁用缓存 [英] How to disable cache on Wildfly

查看:102
本文介绍了如何在Wildfly上禁用缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Wildfly 9上使用了 VRaptor 4 ,我意识到我在本地主机上的导航,在刷新或导航到其他页面时,将正常重新加载HTML内容.但是在另一台主机(例如生产环境)中,我需要清除浏览器缓存以刷新页面.示例:如果我发送一条消息以在视图中显示警报并在其他页面之间导航,而我转到上一页,则警报将保持显示状态.我需要清除缓存以禁用警报.

I'm using VRaptor 4 with Wildfly 9, and I realized that my navigation on localhost, on refresh or nagivation to anothers pages, the HTML content is reloaded normally. But in another host (ex: production), i need clear the browser cache to refresh page. Example: If I send a message to show a alert in view and navigate between another pages, and I go to the previous page, the alert remains displayed. I need clear the cache to disable the alert.

我该如何解决?

推荐答案

您可以在undertow子系统中设置响应标头过滤器.

You can set a response-header filter in the undertow subsystem.

<subsystem xmlns="urn:jboss:domain:undertow:1.2">
   ...
   <server name="default-server">
      <host name="default-host" alias="localhost">
         ...
         <filter-ref name="cache-control" predicate="path-suffix['.jsp'] or path-suffix['.jsf']"/>
      </host>
   </server>

   <filters>
      <response-header name="cache-control" header-name="Cache-Control" header-value="no-cache"/>
   </filters>
</subsystem>

关于谓词过滤器语法,请参见 http ://undertow.io/undertow-docs/undertow-docs-1.2.0/predicates-attributes-handlers.html .功能强大.上面的示例将为每个jsp/jsf页面发送一个不缓存的Cache-Control标头,就用户体验和服务器负载而言,这可能是非常有害的.明智地选择不缓存的内容.

Regarding the predicate filter syntax, see http://undertow.io/undertow-docs/undertow-docs-1.2.0/predicates-attributes-handlers.html. It's powerful. My example above would send a no-cache Cache-Control header for each and every jsp/jsf page, which might be quite evil in regards to user experience and server load. Choose whisely what not to cache.

这篇关于如何在Wildfly上禁用缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆