我必须有一些非常明显的东西,但这里有:
我们网页的大部分内容都是由服务器端包含或后页加载AJAX调用生成的,因此HTML文件的大小通常相当小。但是,在创建测试页时,没有任何复杂的内容,我发现如果页面大小超过8000个字符,服务器就不会传输页面。
这是一个示例文件:
<!DOCTYPE html>
<html>
<head>
<title>Rubbish</title>
</head>
<body>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<br />
重复最后一行16次,共计17条完整线。然后添加一行的这一部分:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliq.<br />
</body>
</html>
上面总共有8001个字符没有加载消息“Safari无法加载页面,因为服务器意外关闭了连接”以及Firefox和Chrome的变化。删除最后一个句号或任何其他字符会使字符数减少,因此页面会按预期加载。
有人能给我一些关于我无法加载这样一个简单文件的遗漏的线索吗?
答案(某种程度):显然是mod_deflate造成了这个问题,所以在一些谷歌搜索之后,我在serverfault上询问是否有人知道如何更改最大尺寸。没有响应所以我创建了一个shell文件,并将原始的8000字符文件包含在服务器端包含(SSI)中,现在它按预期工作。仍然不知道为什么在纯粹的HTML上有限制但在SSI上没有限制,但我没有时间再担心它了。编辑:删除了'SetOutputFilter DEFLATE'指令,页面现在加载,这表明它确实是导致问题的deflate模块。添加'DeflateBufferSize 10000'(或者确实是'DeflateBufferSize 2048')对支持的大小没有任何影响,所以我将关闭这个问题并询问有关服务器故障的模块deflate。
编辑:对不起,应该提到我们在Fedora 14上使用Apache 2.2.17。这是在我的笔记本电脑上的虚拟机上,因此不涉及外部因素。 编辑:我应该添加的另一件事是,即使将loglevel设置为debug,Apache错误日志中也没有任何内容。访问日志提供“200”消息,但发送的字符数设置为“ - ”。 编辑:以下是httpd.conf编辑,没有其他配置文件。输出被缩小,然后由客户端解压缩:
### Section 1: Global Environment
ServerTokens prod
CoreDumpDirectory /tmp
ServerRoot "/etc/httpd"
PidFile run/httpd.pid
Timeout 120
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
<IfModule prefork.c>
StartServers 20
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>
<IfModule worker.c>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
Listen 80
#SOME LOAD MODULE CONFIG LINES REMOVED
LoadModule include_module modules/mod_include.so
LoadModule env_module modules/mod_env.so
LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule expires_module modules/mod_expires.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
LoadModule dav_module modules/mod_dav.so
LoadModule status_module modules/mod_status.so
LoadModule info_module modules/mod_info.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule actions_module modules/mod_actions.so
LoadModule cache_module modules/mod_cache.so
LoadModule cgi_module modules/mod_cgi.so
Include conf.d/*.conf
ExtendedStatus Off
User apache
Group apache
### Section 2: 'Main' server configuration
ServerAdmin root@localhost
ServerName www.example.com:80
UseCanonicalName Off
DocumentRoot "/var/www/html"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<IfModule mod_userdir.c>
UserDir disabled
</IfModule>
DirectoryIndex index.html index.html.var
AccessFileName .htaccess
<Files ~ "^.ht">
Order allow,deny
Deny from all
</Files>
TypesConfig /etc/mime.types
DefaultType text/plain
<IfModule mod_mime_magic.c>
MIMEMagicFile conf/magic
</IfModule>
HostnameLookups Off
#LOG CONFIG LINES REMOVED
ServerSignature Off
Alias /icons/ "/var/www/icons/"
<Directory "/var/www/icons">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<IfModule mod_dav_fs.c>
DAVLockDB /var/lib/dav/lockdb
</IfModule>
IndexOptions FancyIndexing VersionSort NameWidth=* HTMLTable Charset=UTF-8
#ICON CONFIG LINES REMOVED
ReadmeName README.html
HeaderName HEADER.html
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
#LANGUAGE CONFIG LINES REMOVED
AddDefaultCharset UTF-8
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
AddHandler send-as-is asis
AddHandler type-map var
AddOutputFilter INCLUDES .html .xml
AddType application/x-httpd-php .php .html
Alias /error/ "/var/www/error/"
<IfModule mod_negotiation.c>
<IfModule mod_include.c>
<Directory "/var/www/error">
AllowOverride None
Options IncludesNoExec
AddOutputFilter Includes html
AddHandler type-map var
Order allow,deny
Allow from all
LanguagePriority en es de fr
ForceLanguagePriority Prefer Fallback
</Directory>
</IfModule>
</IfModule>
#BROWSER MATCH CONFIG LINES REMOVED
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
<Location /server-info>
SetHandler server-info
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
### Section 3: Virtual Hosts
NameVirtualHost *:80
FcgidMaxRequestLen 2000000
FcgidMinProcessesPerClass 5
FcgidIdleTimeout 18000
FcgidIOTimeout 60
TraceEnable Off
SetEnvIf User-Agent ".*MSIE.*" ISIE true
<VirtualHost *:80>
ServerName www.example.com
UseCanonicalName off
DocumentRoot /etc/httpd/www/examples/
DirectoryIndex index.html index.html.var
CheckSpelling on
CheckCaseOnly on
<Directory /etc/httpd/www/examples/>
Options Includes
AllowOverride None
Order Deny,Allow
Allow from all
Header Set Cache-Control "max-age=10"
ExpiresActive On
ExpiresByType text/html "access plus 10 seconds"
ExpiresByType image/gif A259200
ExpiresByType image/jpg A3600
ExpiresByType text/html A259200
ExpiresByType image/ico A259200
SetOutputFilter DEFLATE
</Directory>
<Directory />
Order Deny,Allow
Deny from All
</Directory>
#OTHER DIRECTORY CONFIG LINES REMOVED
</VirtualHost>
答案 0 :(得分:1)
我最近遇到了与此类似的问题,但使用的是PHP。问题是我启用了输出缓冲。因此,只要我的页面达到某个神奇的字符限制,就会发送输出(因为缓冲区已满),因此在该点之后设置的任何标题都将失败。也许你有类似的问题? (你的缓冲区将是8K字符)
不确定您使用的是vanilla HTML还是某种中间语言......但我会检查所有相关语言/技术的所有设置。
答案 1 :(得分:1)
8000个字符是Apache源代码
中MAX_STRING_LEN的定义