这是控制器代码
public function publish($id){
if(Article::where('id',$id)->update(['status'=>'1'])){
return redirect('admin/article/index')->with('success','发布成功-'.$id);
}
return redirect()->back()->with('fail','操作失败');
}
public function offline($id){
if(Article::where('id',$id)->update(['status'=>'0'])){
return redirect('admin/article/index')->with('success','下线成功-'.$id);
}
return redirect()->back()->with('fail','操作失败');
}


我的操作是点击发布和下线,改变的只是状态字段,跳转处理后还是回到当前页面
用的是phpstudy 里的php7.0+apache laravel 5.2版本
想不明白本地测试得这么慢的

好像是加载js和css占得太多,该怎么优化?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
老问题天天问。 mysql连接用127.0.0.1而不是localhost。
慢的原因是localhost解析到ipv6了,然后tcp连接1秒,超时,转而链接ipv4,所以导致了不管干什么都在1秒以上了。
尽可能保证在0.1秒之下,最好。