[英]The query string seems to affect page loading speed
I'm working on this . 我正在为此工作。 It's hosted on c9.io, a browser based collaborative programming IDE 它托管在基于浏览器的协作编程IDE c9.io上
I have an index.php with a small script: 我有一个带小脚本的index.php:
<?php
$path = ltrim($_SERVER['REQUEST_URI'], '/');
$elements = explode('/', $path);
if(is_numeric($elements[0])){
require_once 'post.php';
}elseif($elements[0]==''){
require_once 'main.php';
}else{
require_once '404.php';
}
?>
When there is nothing in the url (only https://dickbutt-etaoin.c9.io ) it displays the page pretty much instantly but keeps loading for another five seconds during which none of the javascript on the page works 如果网址中没有任何内容(仅https://dickbutt-etaoin.c9.io ),它将立即显示该页面,但会继续加载五秒钟,在此期间,该页面上的所有JavaScript均不起作用
When I have a few numbers (for instance https://dickbutt-etaoin.c9.io/241 ) it's about as fast as it gets. 当我有几个数字(例如https://dickbutt-etaoin.c9.io/241 )时,它的速度差不多。
How can I make both the pages load at a normal speed? 如何使两个页面均以正常速度加载?
I've tried reversing the order of if statements and it doesn't change a thing. 我已经尝试过反转if语句的顺序,并且它不会改变任何事情。 Both the pages are relatively big, contain both php and javascript and a giant css file. 这两个页面都相对较大,包含php和javascript以及巨大的css文件。
After some prodding in the network tab and googling, I found my answer. 经过对网络标签的搜索并进行了谷歌搜索之后,我找到了答案。
I added this line of code to index.php 我将这行代码添加到index.php
header('Connection: close');
Now it does what I wanted it to do. 现在它做了我想要的事情。 Thank you all for trying to help! 谢谢大家的帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.