The problem is simple to explain. If I visit a page of the website, then I login and after I come back to that page, I see that page like I wasn't logged in. If I refresh the page, then the correct version is loaded.
I know that probably this is a question asked many times... But I'm trying to find a solution since days and nothing work; I also read a lot of other threads.
One of my last attempts was this PHP code:
if ( is_user_logged_in() ) :
header('Expires: Sun, 01 Jan 2014 00:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');
endif;
And this HTML:
<?php if ( is_user_logged_in() ) :
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="expires" CONTENT="0">
<?php endig; ?>
I'm using the plugin Autoptimize for caching, but it's the same problem even if is I disable it.
To conclude, my goal would be avoid logged in users to see cache pages.
Any help or tip would be immensely appreciate (if you want to have a look I can give you the website link).
Thanks
UPDATE:
header("Cache-Control: no-cache, must-revalidate"); //HTTP 1.1
header("Pragma: no-cache"); //HTTP 1.0
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");