【发布时间】:2020-07-20 17:35:18
【问题描述】:
挑战/问题
https://www.example.com/nachhilfe-hamburg/ 需要 几秒钟来加载(在我这边,在第一个内容/任何内容可见之前 3-4 秒)。
如果我使用 Google PageSpeed Insights https://developers.google.com/speed/pagespeed/insights/ 检查它,它似乎 ok,至少没有那么多加载,因为它需要 相比之下 到那里的其他网站,例如这个非常相似的页面的页面速度要快得多https://www.example.com/nachhilfe-online.php。是什么导致了这个加载时间过长?
我的论文
这是因为 重定向 和/或因为 .htaccess 有问题。对于https://www.example.com/nachhilfe-hamburg/ 页面,它通常是在.htaccess 中基于此创建的:
RewriteRule ^nachhilfe-(hamburg)/$ /nachhilfe-stadt.php?stadt=$1 [NC,L]
我还检查并检查了控制台,但似乎没有任何东西会对加载时间产生影响。
可能相关的.htaccess 部分:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC]
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{THE_REQUEST} /index\.php
RewriteRule ^index\.php https://www.%{HTTP_HOST}/ [R=301,L]
RewriteRule ^Index\.php$ /index.php [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(html?|php)\ HTTP/
RewriteRule ^index\.(html?|php)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule ^index\$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule ^nachhilfe-(hamburg)/$ /nachhilfe-stadt.php?stadt=$1 [NC,L]
目前有助于提高页面速度的当前方法
- 将“延迟”附加到所有非必要脚本(某些 Google 脚本确实减去了一些 Google PageSpeed 积分)
- 将 png 转换为 jpg
- 延迟加载所有未显示在顶部的图像
- 寻找更有效地嵌入 youtube 的解决方案(现在有一个占位符,只有在点击时才会加载视频并连接到 youtube)
【问题讨论】:
标签: php .htaccess redirect pagespeed