Hello,
I have the problem that when redeploying an application where images or js has changed those changes are not shown due to browser caching.
What i am looking for is a way to either disable browser caching or being able to clear the cached elements.
I have tried the following:
1. Override the phaselistener with the following and added it to the faces lifecycle:
| public void beforePhase(PhaseEvent event) |
| { |
| | FacesContext facesContext = event.getFacesContext(); |
| | HttpServletResponse response = (HttpServletResponse) facesContext |
| | .getExternalContext().getResponse(); |
| | response.addHeader("Pragma", "no-cache"); |
| | response.addHeader("Cache-Control", "no-cache"); |
| | // Stronger according to blog comment below that references HTTP spec |
| | response.addHeader("Cache-Control", "no-store"); |
| | response.addHeader("Cache-Control", "must-revalidate"); |
| | // some date in the past |
| | response.addHeader("Cache-Control", "max-age=1"); |
| } |
These cathing options does seem to be applied to images and js.
2. Adding filters by adding to web.xml
<filter>
<filter-name>ACF</filter-name>
<filter-class>oracle.adf.view.rich.webapp.AdfFacesCachingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ACF</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>
Which does seem to change the
Next i added the cache-rules to the adf-config.xml however they do not seem to override the default values and i still just get the cache-control: public, max-age=99999. Images are stille caches and does not change without clearing of the browser cache!
The following is my adf-config.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<adf-config xmlns="http://xmlns.oracle.com/adf/config" xmlns:config="http://xmlns.oracle.com/bc4j/configuration"
xmlns:adf="http://xmlns.oracle.com/adf/config/properties">
<adf-adfm-config xmlns="http://xmlns.oracle.com/adfm/config">
<caching-rules xmlns="http://xmlns.oracle.com/adf/faces/rich/acf">
<caching-rule id="cache_png">
<cache>false</cache>
<compress>false</compress>
<duration>1</duration>
<agent-caching>false</agent-caching>
<cache-key-pattern>*.png</cache-key-pattern>
</caching-rule>
<caching-rule id="cache_css">
<duration>1</duration>
<agent-caching>false</agent-caching>
<cache-key-pattern>*.css</cache-key-pattern>
</caching-rule>
<caching-rule id="cache_js">
<duration>1</duration>
<agent-caching>false</agent-caching>
<cache-key-pattern>*.js</cache-key-pattern>
</caching-rule>
<caching-rule id="cache_jpg">
<cache>false</cache>
<compress>false</compress>
<duration>1</duration>
<agent-caching>false</agent-caching>
<cache-key-pattern>*.jpg</cache-key-pattern>
</caching-rule>
<caching-rule id="cache_jpeg">
<cache>false</cache>
<compress>false</compress>
<duration>1</duration>
<agent-caching>false</agent-caching>
<cache-key-pattern>*.jpeg</cache-key-pattern>
</caching-rule>
<caching-rule id="cache_gif">
<cache>false</cache>
<compress>false</compress>
<duration>1</duration>
<agent-caching>false</agent-caching>
<cache-key-pattern>*.gif</cache-key-pattern>
</caching-rule>
<caching-rule id="cache_html">
<compress>true</compress>
<duration>1</duration>
<agent-caching>false</agent-caching>
<cache-key-pattern>*.html</cache-key-pattern>
</caching-rule>
<caching-rule id="cache css">
<duration>4</duration>
<agent-caching>true</agent-caching>
<cache-key-pattern>*.css</cache-key-pattern>
</caching-rule>
<caching-rule id="cache js">
<duration>4</duration>
<agent-caching>true</agent-caching>
<cache-key-pattern>*.js</cache-key-pattern>
</caching-rule>
<caching-rule id="cache png">
<compress>false</compress>
<duration>4</duration>
<agent-caching>true</agent-caching>
<cache-key-pattern>*.png</cache-key-pattern>
</caching-rule>
<caching-rule id="cache jpg">
<compress>false</compress>
<duration>4</duration>
<agent-caching>true</agent-caching>
<cache-key-pattern>*.jpg</cache-key-pattern>
</caching-rule>
<caching-rule id="cache jpeg">
<compress>false</compress>
<duration>4</duration>
<agent-caching>true</agent-caching>
<cache-key-pattern>*.jpeg</cache-key-pattern>
</caching-rule>
<caching-rule id="cache gif">
<compress>false</compress>
<duration>4</duration>
<agent-caching>true</agent-caching>
<cache-key-pattern>*.gif</cache-key-pattern>
</caching-rule>
<caching-rule id="cache html">
<compress>true</compress>
<duration>4</duration>
<agent-caching>true</agent-caching>
<cache-key-pattern>*.html</cache-key-pattern>
</caching-rule>
</caching-rules>
<defaults changeEventPolicy="ppr" useBindVarsForViewCriteriaLiterals="true" useBindValuesInFindByKey="true"
mapNegativeScaleToIntegerTypes="true" executeEmptyOnException="true"/>
<startup>
<amconfig-overrides>
<config:Database jbo.locking.mode="optimistic"/>
</amconfig-overrides>
</startup>
</adf-adfm-config>
<adf:adf-properties-child xmlns="http://xmlns.oracle.com/adf/config/properties">
<adf-property name="adfAppUID" value="Application1.asd"/>
</adf:adf-properties-child>
</adf-config>
I have also tried to move the rules outside of </adf-adfm-config> but with same result.
I am using Jdev. 12.1.2.0.0.
Its really important that the js and images are refreshed after a redeployment the users should not clear there cache in order for the application to work.
TIA