使用别名域名访问本地Django服务器时静态内容加载缓慢
我把域名加到了我的 /etc/hosts/ 文件里,现在我的网站可以访问了,但静态内容加载得慢得让人受不了。正常情况下,一个页面从本地加载只需要0.8秒,但现在却要30秒。我完全不知道为什么会这样,这真是影响我的工作效率。我甚至还格式化了我的电脑,想看看能不能解决这个问题,但还是没用。这是在最新版本的Mac OS X上出现的情况。
所以,http://localhost:8000 运行得很好,非常快,而 http://mydomain.com:8000 却慢得让人抓狂。
我不能使用localhost或127.0.0.1,因为这是一个需要用到Facebook连接的应用,而他们最近不再允许这两个作为应用的有效网址了。
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 mydomain.com
1 个回答
1
我建议用SimpleHTTPServer来测试一下,看看这个问题是不是跟Django有关:
python -m SimpleHTTPServer