wordpress加载慢
It's no secret that my website tends to get slow during high periods of traffic and I believe I identified one of the big problems. I've found that one of the plugins I use has an incorrect ".css" reference that is 404ing. That means, of course, that instead of loading a CSS file, it's loading my 404 page. Long story short, the page is essentially loading at least twice. No more of that. Although I have put a blank file where that CSS reference is supposed to go, I've thought of a way to not let that happen again.
在高流量期间我的网站趋向于变慢已经不是什么秘密了,我相信我发现了其中一个大问题。 我发现我使用的其中一个插件具有不正确的“ .css”引用,即404ing。 当然,这意味着不用加载CSS文件,而是加载我的404页面。 长话短说,该页面实际上至少加载了两次。 没有更多了。 尽管我在应该放置CSS参考的地方放了一个空白文件,但我想到了一种不让这种情况再次发生的方法。
PHP (The PHP)
header('HTTP/1.1 404 Not Found');
$uri = strtolower($_SERVER['REQUEST_URI']);
if(strstr($uri,'.css') || strstr($uri,'.js') || strstr($uri,'.txt') || strstr($uri,'.jpg') || strstr($uri,'.gif')) { die(''); }
Inside the 404.php file, I sniff for a file extension of JS, CSS, etc. If I find a match, I simply "die out" the page which prevents the 404 page from loading. However if the user legitimately hits a 404 page, I display the "sorry..." page.
在404.php文件中,我嗅探到JS,CSS等文件扩展名。如果找到匹配项,我只是“消灭”该页面,从而阻止了404页面的加载。 但是,如果用户合法地访问了404页面,则显示“对不起...”页面。
Of course this isn't the only issue (I think Dreamhost may have slow servers) but this should help out a lot!
当然,这不是唯一的问题(我认为Dreamhost的服务器速度可能很慢),但这应该会有所帮助!
wordpress加载慢