在“localhost”上运行站点非常慢
使用我的本地主机测试站点确实遇到麻烦。它运行得极其缓慢!有时加载页面需要长达一分钟的时间。我正在使用 Firefox,并且我正在测试的网站在我办公室的本地计算机/生产服务器上的其他开发人员上运行良好。
我已经经历了正常的事情:-
- 禁用 IPv6
- 未在调试模式下运行
- 将站点置于 IIS 6 上的最高应用程序池(高隔离)中。
- 采用防火墙等。
该问题似乎仅在访问包含某些内容的页面时才会出现代码隐藏中的 .net 代码形式。
欣赏这个有点模糊的主题/在黑暗中刺探,但我会感激任何形式的建议 - 每次刷新都要等一分钟来尝试改变,这太可怕了!
干杯,肖恩。
Having real trouble using my localhost to test sites. It runs extremely slowly! Sometimes it takes up to a minute to load a page. I'm using Firefox and the sites I'm testing run fine on other developers in my office's local machines / on the production server.
I've gone through the normal things :-
- Disabled IPv6
- Not running in debug mode
- Put the site in the highest app pool (High Isolated) on IIS 6.
- Taking of firewalls etc.
The problem only seems to occur when hitting pages which contain some form of .net code in the code-behind.
Appreciate that this a little bit of a vague topic / stab in the dark but would appreciate any sort of advice - it's horrible waiting a minute each refresh to try out a change!
Cheers, Sean.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(20)
我在使用 PHP 时也遇到了同样的问题。我通过将数据库连接参数中的“localhost”更改为“127.0.0.1”来解决这个问题,就像有人在这里建议的那样: https://serverfault.com /a/444338/62739 。我想它可能也适合你,尝试一下。
I had the same problem with PHP. I solved it by changing "localhost" to "127.0.0.1" in database connection parameters like someone suggested here: https://serverfault.com/a/444338/62739 . I think it may work for you too, give it a try.
只是分享我的解决方案...我将浏览器中的网址从 localhost:port 更改为 127.0.0.1:port 这导致加载速度非常快
Just Sharing my solution... i changed the url in my browser from localhost:port to 127.0.0.1:port which resulted in very fast loading
我遇到了同样的问题,编辑了我的主机文件 127.0.0.1 localhost,但发现没有区别。
然后,我在 IIS 面板中禁用了压缩并应用,问题现在似乎已得到解决。
IIS管理器>压缩>取消选中“启用动态内容压缩”并取消选中“启用静态内容压缩”。然后“应用”。
I had same issues, edited my hosts file 127.0.0.1 localhost, but noticed no difference.
I then disabled Compression in the IIS panel and applied, and problem appears to now be resolved.
IIS Manager > Compression > Uncheck 'Enable dynamic content compression' and uncheck 'Enable static content compression'. Then 'Apply'.
我遇到了同样的问题,IIS 初始加载最多需要 10 分钟,而不是通常的 30 秒。
我打开任务管理器来查看正在运行的进程。事实证明,当第一次访问 IIS 端点时,Windows Defender 的 CPU 使用率会飙升至 30%。我尝试排除我的 /bin/ 文件夹,但这不起作用,所以我只是禁用了 Windows Defender 上的实时保护,瞧,网站在短短 30 秒内就加载了。
I was having the same issue, IIS initial loading would take up to 10 minutes instead of the usual 30 seconds.
I opened up Task Manager to see what processes were running. Turns out Windows Defender would spike at 30% CPU usage when hitting the IIS endpoint for the first time. I tried excluding my /bin/ folders but that did not work, so I just disabled real-time protection on Windows Defender and voilà the site was loading in just 30 seconds.
尝试启用绕过本地地址的代理服务器。这适用于所有已安装的浏览器(Firefox、Chrome 等)。
通过单击“开始”按钮打开 Internet Explorer
开始按钮。在搜索框中,键入 Internet Explorer,然后,
在结果列表中,单击 Internet Explorer。
单击“工具”按钮,然后单击“Internet 选项”。
单击“连接”选项卡,然后单击“LAN 设置”。
选中“为 LAN 使用代理服务器”复选框。
选择对本地地址绕过代理服务器
Try to enable the Bypass proxy server for local addresses. This works for all browsers installed (Firefox, Chrome, etc).
Open Internet Explorer by clicking the Start button Picture of the
Start button. In the search box, type Internet Explorer, and then,
in the list of results, click Internet Explorer.
Click the Tools button, and then click Internet Options.
Click the Connections tab, and then click LAN settings.
Select the Use a proxy server for your LAN check box.
Select the Bypass proxy server for local addresses
禁用 Web 应用程序代码所在文件夹的防病毒软件。就我而言,我发现 Avast 防病毒软件有了很大的改进。
Disable the antivirus on the folders where is the code of the web application. In my case I have observed a big improvement with Avast antivirus.
这个建议为我解决了这个问题。清除 C:\Users\用户名\AppData\Local\Microsoft\WebSiteCache 中的 WebSiteCache
This suggestion fixed it for me. Clear out the WebSiteCache in C:\Users\username\AppData\Local\Microsoft\WebSiteCache
http://blog.geocortex.com/2007/12/07/slow-visual-studio-performance-solved/
对于使用 Mac 的人来说。当您使用不同的主机名时,例如 test.local 和 test2.local。尝试将 test.local 更改为 test.dev。我发现 Mac OS X lion 控制着 .local tld。因此,当您将其更改为其他内容时,速度会更快。
当然,请使用上面的建议,例如关闭主机文件中的 ipv6 引用:
#::1 localhost
并在主机文件中进行设置:
127.0.0.1 localhost
因此它指向 ipv4。
For people using a mac. When you're using different host names say test.local and test2.local. Try changing test.local to test.dev. I found out that Mac OS X lion controls the .local tld. So when you change it to something else it's faster.
And of course use above suggestions like turning off the ipv6 reference in your hosts file:
#::1 localhost
and setting this in the hosts file:
127.0.0.1 localhost
so it points to ipv4.
如果您只是查看页面输出(而不是调试代码),则转到 Web.Config 文件并将 debug 设置为 false。这会将加载时间从 >15 秒更改为 <1 秒
If you are just viewing the page output (not debugging code) then go to the Web.Config file and set debug to false. This changes load time from >15 secs to <1 sec
如果您使用 .Net,那么关闭 Web.Config 中的调试将会无休止地提高性能。
If your using .Net then turning off debug in your Web.Config is going to improve performance no end.
我刚刚将主机文件从以下位置更改
为
I just changed my hosts file from this:
to
我知道该操作员使用的是旧版本的 IIS,这可能不适用于他,但我发布此内容是因为它可能对其他人有帮助。我遇到了同样的问题,以上 IPv6 或主机文件更改对我来说都不起作用。我的 asp.net MVC4 项目在按 F5 刷新本地主机上的 js 更改后非常慢。所有浏览器都发生这种情况 - Chrome、FF 和 IE。最终我意识到我在本地运行 IIS Express 8.0,结果发现 8.0 在提供 js 文件时非常慢,而且似乎是一个错误。如果我在命令行上运行 iisexpress 并按 F5,我可以看到每个 js 文件需要 4 或 5 秒才能加载。
我最终卸载了 IIS 8.0 并安装了 IIS Express 7.5,问题立即得到解决。以下是我遵循的步骤:
IIS Express 8.0 似乎是与 VS 2012 一起安装的,因此如果您进行了全新安装或可能进行了服务包更新这可能会升级以前的 IIS Express 版本。
I know the op was using an older version of IIS and this may not apply to him, but I'm posting this as it might help others. I had the same problem and none of the above IPv6 or hosts file changes worked for me. My asp.net MVC4 project was really slow after hitting F5 to refresh js changes on localhost. It was happening across all browsers - Chrome, FF, and IE. Eventually I realised I was running IIS Express 8.0 locally, and it turns out 8.0 is extremely slow when serving up js files and seems to be a bug. If I ran iisexpress on the command line and hit F5 I could see each js file took 4 or 5 seconds to load.
I ended up uninstalling IIS 8.0 and installing IIS express 7.5 and straight away the problem was fixed. Here are the steps I followed:
IIS Express 8.0 seems to be installed with VS 2012 so if you had a new install or possibly a service pack update this might upgrade the previous IIS Express version.
我正在使用 Wamp Server、Windows 7 和功能强大的机器。
我的 Apache 配置为从端口 80 以外的其他端口运行。我也不是通过“localhost”访问本地站点,而是通过 dyn.com 映射到我的 IP 的主机名。我相信我运行的端口与 80 不同,这一事实似乎使卡巴斯基的网络反病毒功能非常敏感(因为许多粗略的网站运行不同的端口)并减慢速度
禁用它似乎已经解决的问题。
I'm using Wamp Server, Windows 7 and a powerful machine.
My Apache is configured to run from a different port other than port 80. I also access my local site not via 'localhost', but a hostname mapped to my IP via dyn.com. I believe the fact that I'm running off of a different port than 80 seems to make Kaspersky's Web Anti-Virus feature very sensitive (since a lot of sketchy sites run off of different ports) and slows things down
Disabling it seems to have solved the issue.
我通过编辑 phpmyadmin 文件夹中的 config.inc.php 文件解决了这个问题:
具体将
$cfg['Servers'][$i]['host'] = 'localhost'
更改为$cfg['Servers'][$i]['host'] = '127.0.0.1'
I fixed this problem by editing
config.inc.php
file which is inphpmyadmin
folder:specifically changed
$cfg['Servers'][$i]['host'] = 'localhost'
to$cfg['Servers'][$i]['host'] = '127.0.0.1'
构建项目后,网站需要一些时间来浏览新的 dll:)。
重建后加载网页需要一些时间,这是正常的。当仅更改 JavaScript 等内容时,不应发生这种情况。
After building your project the website needs some time to walk through the new dll :).
It's normal that loading a webpage after rebuilding takes some time. This shouldn't happen when only changing something in for example javascript.
运行进程监视器以查看正在消耗哪些资源(网络、文件、注册表、线程),并查看正在消耗任何不必要的资源(远程 https、昂贵的文件读取)
我遇到了类似的问题。当我运行进程监视器时,我发现我的融合日志已启用,因此磁盘中有很多内容,这在禁用融合日志 IIS Express 后延迟了 dll 的加载,速度更快。
Run the Process Monitor to see what resources(Network, File, Registry, Threads) are being consumed and see any unnecessary resource(remote https, costly file reads) are being consumed
I had similar problem. When I run the process monitor I found that my fusion log is enabled so there are many into the disk which delayed the loading of dll after disabling fusion log IIS Express it is faster.
对我来说,原因是该项目位于网络驱动器上。我将项目移至 C: 驱动器,一切都运行顺利,没有任何延迟。
如果项目位于网络驱动器上,请尝试将其移动到本地 C: 驱动器,然后重试。
性能的提升远远超出您对网络速度的预期。我猜想 VS 在调试 ASP.NET MVC 应用程序时会不断访问文件。我在 IIS Express 上使用 VS 2017、ASP.NET MVC 调试,这对我有用。
我希望这有帮助。
The cause of this for me was that the project was located on a network drive. I moved the project to the C: drive and everything ran without any delay.
If the project is located on a network drive, try moving it to your local C: drive and try it again.
The performance increase is much more than you would expect from just network speed. I guess VS is continually accessing the files when debugging an ASP.NET MVC application. I was using VS 2017, ASP.NET MVC debugging on IIS Express and this worked for me.
I hope this helps.
就我而言,最初发生了以下错误:
我使用建议的解决方案修复了错误,并通过
IIS重新启动了应用程序经理。原来的错误消失了,但应用程序加载时间很长。我再次向
IIS_IUSRS
授予权限,但这次是向整个部署文件夹授予权限。此后,应用程序能够加载,尽管出现错误:使用解决方案解决上述错误后,应用程序最终在没有加载的情况下加载给出任何错误。
In my case, originally the following error was occurring:
I fixed the error by using the proposed solution and restarted the application through
IIS Manager
. The original error was gone but the application was taking forever to load. I gave the permissions toIIS_IUSRS
again but this time to the whole deployment folder. After this, the application was able to load though an error was showing up:After resolving the above-mentioned error using the solution, the application was finally loading without giving any error.
请注意,您的项目可能存在一些问题:
希望这有帮助..
See, Here may be some problems with your project:
Hope this helps..
启用 SQL Server TCP/IP 协议
在我的例子中,在 localhost 上运行的测试站点的每个页面需要 5 到 10 秒才能加载。这些相同的页面在临时生产环境中几乎立即加载。对我有用的解决方案是在 Sql Server 配置管理器中启用 TCP/IP 协议。启用 TCP/IP 并重新启动 Sql Server 服务后,我的本地网站的响应速度与部署的网站一样快。
Enable SQL Server TCP/IP protocol
In my case it was taking 5 to 10 seconds for each page of my test site running on localhost to load. These same pages load almost instantly in staging an production environments. The solution that worked for me was to enable TCP/IP protocol in Sql Server Configuration Manager. Once I enabled TCP/IP and restarted the Sql Server Service my local website was just as responsive as the deployed ones.