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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With