How to disable cache on Wildfly

青春壹個敷衍的年華 提交于 2019-12-10 15:38:02

问题


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.

How I can fix it?


回答1:


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>

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.



来源:https://stackoverflow.com/questions/37705378/how-to-disable-cache-on-wildfly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!