I am working on site where potentially two different users could login to the same browser without it having been closed.
This can allow the second user to use the back button and see cached pages belonging to the first user. I can't find a way of preventing the second user from seeing the previous users cached history.
I know it is possible, what is the best way to achieve this?
i hope this article helps you
Here are some headers that I usually throw on any page where I do not want to cache
<cfheader name="expires" value="#now()#">
<cfheader name="pragma" value="no-cache">
<cfheader name="cache-control" value="no-cache, no-store, must-revalidate">
Thanks for your answers, very useful.
From what I understand Mike, this approach doesn't work in all browsers, is that correct? I have tried similar approaches and they didn't work for me.
If you are also using session variables you may want to read this about Ending a session
Of course that assumes the user actually performs some logout step. Without the browser being closed all requests will use the same session as far as ColdFusion is concerned. Be careful!
Little_Mike is incorrect. Those headers have proved inefficient on many occasions, depending on the browser the user is using. The two fixes that I have found to be foolproof to never worry about caching, are these:
1. You use a <cfset Sleep(5000)> at the top of the page. This will cause the browser and the server to have enough time to catch up to the latest version of the page, and not revert back to a cached version.
2. Use a cflocation to the current page. This will essentially reload the page, and all new information will be available on the page.
Little_Mike is definitely disseminating incorrect ColdFusion information.
Mike blindly throws out a bunch of cfheader tags with reckless abandon, seemingly unconcerned about the cross-browser effects.
Clearly, the appropriate solution in these circumstances is to use the cross-browser compatible tag <cfcontent> as follows:
<cfcontent reload="true" content="refresh" page="reload">
I am interested to know where you have used that code jerseycat10? None of those attributes that you have listed can be used with the cfcontent tag. I have used the same cfheader tags that Little_Mike listed for years. They work.
Here is the CF9 documentation for the cfcontent tag: http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461 172e0811cbec22c24-7c82.html
Europe, Middle East and Africa