繁体   English   中英

登录后重定向,缓存页面问题-Javascript

[英]Redirect after login , cached page issue - Javascript

我在登录ajax后遇到重新创建重定向的问题,本质上是在正确登录之后(例如,从主页),我被重定向到了新页面。 当我在这个新页面中时,如果我单击将我带回到首页的链接,则该首页处于未记录版本。 好像浏览器维护一个缓存版本。 实际上,只需用F5更新此页面,页面就会刷新,并且我登录了。

你有什么建议吗?

编辑:我正在使用Wordpress LoginWithAjax插件

/Make Ajax Call
    $.post(url, postData, function(data){
        lwaAjax( data, 'LoginWithAjax_Status', '#login-with-ajax' );
        if(data.result === true){
            //Login Successful - Extra stuff to do
            if( data.widget != null ){
                $.get( data.widget, function(widget_result) {
                    $('#LoginWithAjax').replaceWith(widget_result);
                    $('#LoginWithAjax_Title').replaceWith($('#LoginWithAjax_Title_Substitute').text());
                });
            }else{
                if(data.redirect == null){
                    window.location.reload();
                }else{
                    window.location = data.redirect;
                }
            }
        }
    }, "json");
}); 

如果您正确设置了会话(如您在评论中提到的那样),则可能是浏览器缓存。 您可以尝试向页面添加标题,要求浏览器不要缓存:

<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>

在此论坛帖子上了解更多信息: http : //www.webmasterworld.com/forum21/10628.htm

好吧,这似乎正在工作! 谢谢托什。

<?php 
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM