Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable cache on Wildfly

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?

like image 253
Ricardo Farias Avatar asked Feb 07 '23 20:02

Ricardo Farias


1 Answers

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.

like image 132
T. Kuther Avatar answered Feb 24 '23 04:02

T. Kuther