Firefox 的网站速度极其缓慢,但在其他浏览器上即时运行:KeepAlive 问题?

发布于 2024-09-12 22:01:35 字数 1868 浏览 10 评论 0原文

我有一个网站,使用 Firefox 加载页面需要 10 秒,加载图像还需要 10 秒。这是一个在 apache 上运行的 php 页面。这些图像只是静态图像。

它在 chrome 上运行得很好......即时加载。

谷歌搜索答案让我发现了一个可能的问题,即保持活动状态和内容长度的缺乏使火狐感到困惑,事实上,内容长度似乎不是由服务器在静态或非静态内容上设置的,而是禁用在服务器上保持活动状态会使加载时间加倍!

一些网站建议在浏览器上禁用保持活动状态,但我不愿意向所有查看该页面的人推荐这一点!我是不是找错了树?

浏览器是 Lucid Lynx 上的 firefox 3.6.8。服务器是Apache 2.2.11。

apache.conf 已附加...我认为这是开箱即用的,尽管我徒劳地尝试将 KeepAlive 超时减少到 3 并加载页面。

我是不是找错了树?

ServerRoot "/etc/apache2"

LockFile /var/lock/apache2/accept.lock
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 3
<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>
<IfModule mpm_worker_module>
    StartServers          2
    MaxClients          150
    MinSpareThreads      25
    MaxSpareThreads      75 
    ThreadsPerChild      25
    MaxRequestsPerChild   0
</IfModule>
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
AccessFileName .htaccess
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
</Files>
DefaultType text/plain
HostnameLookups Off
ErrorLog /var/log/apache2/error.log
LogLevel warn
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
Include /etc/apache2/httpd.conf
Include /etc/apache2/ports.conf
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined
Include /etc/apache2/conf.d/
Include /etc/apache2/sites-enabled/

I have a site where a page takes 10 seconds to load with firefox, and a further 10 seconds to load the images. It's a php page running on apache. The Images are just static images.

It runs beautifully on chrome.... instant loading.

googling for the answer has pointed me towards a possible issue with keep alive and the lack of content length confusing firefox, and indeed, it appears that content length isn't being set by the server on either the static or non static content, but disabling keep alive on the server doubles the load time!

Some sites have suggested disabling keep alive on the browser, but I'm reluctant to recommend that to everyone that views the page! Am I perhaps barking up the wrong tree?

browser is firefox 3.6.8 on Lucid Lynx. server is Apache 2.2.11.

apache.conf is apended... I think it's the one that comes out of the box, although I reduced the KeepAlive timeout to 3 in a vain attempt to try and get the page to load.

Am I barking up the wrong tree?

ServerRoot "/etc/apache2"

LockFile /var/lock/apache2/accept.lock
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 3
<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>
<IfModule mpm_worker_module>
    StartServers          2
    MaxClients          150
    MinSpareThreads      25
    MaxSpareThreads      75 
    ThreadsPerChild      25
    MaxRequestsPerChild   0
</IfModule>
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
AccessFileName .htaccess
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
</Files>
DefaultType text/plain
HostnameLookups Off
ErrorLog /var/log/apache2/error.log
LogLevel warn
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
Include /etc/apache2/httpd.conf
Include /etc/apache2/ports.conf
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined
Include /etc/apache2/conf.d/
Include /etc/apache2/sites-enabled/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

琴流音 2024-09-19 22:01:35

问题出在本地 DNS 查找上。命令行 DNS 解析似乎没问题,而且 Chrome 速度快如闪电,这一事实掩盖了这个问题。事实证明,chrome 使用 DNS 预取,不使用本地网络堆栈。这让我完全走上了错误的道路。

创建本地绑定服务后,firefox 似乎运行良好。

因此,在与其他浏览器相同的平台上运行 chrome 时需要注意一些事情。

The issue was with local DNS lookup. The issue was hidden by the fact that command line DNS resolution seemed to be OK, and chrome was lightning fast. Turns out that chrome uses DNS prefetching, which doesn't use the local network stack. This threw me onto completely the wrong tack.

After creating a local bind service, firefox seems to be working nicely.

So something to watch out for when running chrome on the same platform as other browsers.

維他命╮ 2024-09-19 22:01:35

不要禁用保持活动状态。它使得一个连接可以用于获取多个页面(或图像、或.js 文件、或.css 文件等),从而显着减少页面加载时间。

只需确保您的脚本添加 Content-Length 标头,一切都会好起来的。

Don't disable keep-alive. It makes that one connection can be used to get multiple pages (or images, or .js files, or .css files, etc.), which reduces page load time significantly.

Just make sure your scripts add Content-Length headers and all will be fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文