Working on some JSF 2.0 project. Have form for adding picture for new/existing user. Can't see a new added picture without refreshing the page (*.xhtml). I tried to put regular:
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
But it not helps.
How can I disable page caching?
The HTML <meta http-equiv>
tags are ignored when the page is been served over HTTP. The <meta http-equiv>
tags are only interpreted when the page is by the enduser been saved to the local disk file system and then opened from it by a file://
URL.
You need to set those headers on the real HTTP response instead. Easiest way is to use a servlet filter which basically does
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setDateHeader("Expires", 0); // Proxies.
chain.doFilter(request, response);
(note that your original Cache-Control
header was incomplete, the above example is the proper usage)
You could map the on the URL pattern of the specific page, but you could also consider to map it on all dynamic pages generated by JSF.