-1

I have the following code in my project (JSF1.2, RF 3.3.3 SR1, GF 3.0.1)

// Following code in PhaseListener
@Override
public void beforePhase(PhaseEvent event) {
    if (event.getPhaseId() == PhaseId.RENDER_RESPONSE) {
        HttpServletResponse res = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
        res.addHeader("pragma", "no-cache, no-store, must-revalidate, max-age=0, s-max-age=0, proxy-revalidate");
        res.addDateHeader("Expires", 0);
        res.addHeader("cache-control", "no-cache, no-store, must-revalidate, max-age=0, s-max-age=0, proxy-revalidate");
    }
}

I tested the above code in IE, FF, Safari and it worked fine.

After upgrading the above project to JSF 2.0 (JSF2.0, RF 4.0.0 Final, GF 3.0.1), the above code is not clearing the cache. I tried to replace addHeader with setHeader with no luck.

Also, I tried to implement the above code in a Filter as mentioned here, but it didn't help.

Thanks in advance,

Praneeth

Community
  • 1
  • 1
Praneeth
  • 1,457
  • 5
  • 23
  • 36

1 Answers1

0

Issue resolved by adding autocomplete="off" to all the h:inputText boxes.

Praneeth
  • 1,457
  • 5
  • 23
  • 36
  • That's not related to browser cache. You should really have clarified the *real* problem from the beginning on (e.g. "input values are autofilled after requesting the page" or something). Browser caching means that the whole page at its own is loaded from browser cache instead of requested from the webserver. You should have seen that easily using a HTTP tracker like as the one in Firebug. – BalusC Aug 19 '11 at 14:43
  • @BalusC In my case, input values were not autofilled after requesting the page. All the input boxes were empty. However, when I hit keyboard down key, I was able to see all the previously entered text. I thought that it was getting the previous values from browser cache - Correct me if I am wrong. Thanks – Praneeth Aug 19 '11 at 14:53
  • Also that should have been clarified in the question. You could also put `autocomplete="off"` on the `` instead of on every individual input component by the way. – BalusC Aug 19 '11 at 14:53
  • `` doesn't have `autocomplete` attribute. It is discussed [here](http://stackoverflow.com/questions/3211442/how-to-do-autocomplete-off-at-form-level-in-jsf) – Praneeth Aug 19 '11 at 15:26