wordpress加载慢_WordPress,404s和加载时间

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的服务器速度可能很慢),但这应该会有所帮助!

翻译自: https://davidwalsh.name/wordpress-404

wordpress加载慢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值