49355

Avoid back page rendering after sign out in

Question:

i've seen:

<a href="https://stackoverflow.com/questions/49547/making-sure-a-web-page-is-not-cached-across-all-browsers/2068407" rel="nofollow">How to control web page caching, across all browsers?</a> <a href="https://stackoverflow.com/questions/10330336/after-logout-click-on-back-button-cache-issue" rel="nofollow">enter link description here</a>

I've used in JSF 1.2 pages:

<meta http-equiv="Cache-control" content="no-store, no-cache, must-revalidate"/> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Expires" content="-1"/> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>

It did not work in IE8 e Chrome! When I use the back button it shows the page again! What is wrong? Regards.

Answer1:

Here's a cite from <a href="https://stackoverflow.com/questions/49547/making-sure-a-web-page-is-not-cached-across-all-browsers/2068407" rel="nofollow">How to control web page caching, across all browsers?</a> which you linked in your question but apparently overlooked:

<blockquote>

Note that when the page is served over HTTP and a header is present in <strong>both</strong> the HTTP response headers and the HTML meta tags, then the one specified in the response header will get precedence over the HTML meta tag. The HTML meta tag will only be used when the page is viewed from local disk file system. See also <a href="http://www.w3.org/TR/html4/charset.html#h-5.2.2" rel="nofollow">W3 HTML spec chapter 5.2.2</a>. Take care with this when you don't specify them programmatically, because the webserver can namely include some default values. To verify the one and other, you can see/debug them using Firebug Net panel.

</blockquote>

This is apparently the case. You need to set those headers on the real HTTP response, not in its HTML output. In case of a JSF 1.x web application the best way is to create a <a href="https://stackoverflow.com/tags/servlet-filters/info" rel="nofollow">servlet filter</a> to perform the task. Here's a kickoff example:

public class NoCacheFilter implements Filter { @Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletResponse response = (HttpServletResponse) res; 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(req, res); } // ... }

Map it in web.xml on an URL pattern of interest, e.g. *.jsf or on the servlet name of the FacesServlet.

Recommend

  • In my Julia 1.0.0 REPL, LOAD_PATH returns unexpected results
  • Python - Use list of points to extract data from gridded NetCDF without for loops
  • Why IE9 +, Chrome and Opera15 + browsers identify themselves as Mozilla in the User Agent?
  • Visualizing a balanced tree
  • Unable to create custom page tracking URL for external links with Universal Analytics Code
  • How to close an authentication pop up window having a cross-domain url?
  • bind values of specific array of a json model to a control in sapui5
  • Counterpart of .NETs NetworkStream / SslStream in Delphi 7 [closed]
  • Grails filters: can't make it work !
  • WordPress - I can't login - Something wrong with the wp_users table
  • How to get poltergeist/PhantomJS to delay returning the page to Capybara until AJAX is loaded?
  • Trying to get a div w/ 100% height and overflow auto to work in Firefox
  • R doesn't open with UTF-8
  • Tkinter Grid Columnspan ignored
  • Prevent date and time insert to the database
  • Openstack.Net SDK cannot access services
  • Overriding window.location on Webbrowser Control
  • How to use both ga.js and analytics.js?
  • Checkpointing In ALS Spark Scala
  • Heroku push rejected - Hartl's Rails 3.2 tutorial
  • Cross platform UI spacing/padding
  • git add error : “fatal : malloc, out of memory”
  • Possible to “watch” both HAML and SASS at the same time?
  • Why cepheus don't send int without quotes to orion?
  • Database structure design with variable amounts of fields
  • Meteor: Do Something On Email Verification Confirmation
  • Change Inet root folder for iis 7
  • Highlight one bar in a series in highcharts?
  • Ajax Loaded meta Tags
  • Xamarin Forms - UWP Fonts
  • Controls, properties, events and timers running in design time
  • Where to put my custom functions in Wordpress?
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Updated Ionic CLI but shows previous version (Windows)
  • XCode can't find symbols for a specific iOS library/framework project
  • RestKit - RKRequestDelegate does not exist
  • Arrays break string types in Julia
  • WPF Applying a trigger on binding failure
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?