red*_*ent 2 php performance redirect
在我们的网站上,我们有一些项目编辑页面.当用户单击"保存"时,表单将发布到同一页面,然后重定向到下一页.出于某种原因,重定向需要很长时间(如60秒).
我在代码中放置了计时措施,我可以告诉你,代码本身的任何内容都不会花费超过1秒的时间来执行.
这是我用来重定向的内容:
header("Location: " . $url, true, 307 ); // 307 is temporary redirect
Run Code Online (Sandbox Code Playgroud)
这是解决问题的方法:
header( 'Content-type: text/html; charset=utf-8' ); // make sure this is set
header("Location: " . $url, true, 307 ); // 307 is temporary redirect
echo "<html></html>"; // - Tell the browser there the page is done
flush(); // - Make sure all buffers are flushed
ob_flush(); // - Make sure all buffers are flushed
exit; // - Prevent any more output from messing up the redirect
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3569 次 |
| 最近记录: |