启用Rails页面缓存会导致http标头字符集消失

|| 我需要将字符集设置为utf-8,默认情况下似乎是如此。最近,我为一些静态页面启用了页面缓存:
caches_page :about
缓存工作正常,并且我在/ public文件夹中看到了相应的about.html和contact.html页面,除非页面呈现后,它不再位于utf-8中。 谷歌搜索了一下之后,我尝试在缓存前后使用wget查看http头: 第一次:
$wget --server-response http://localhost:3000/about

HTTP request sent, awaiting response... 
 1 HTTP/1.1 200 OK
 2 X-Ua-Compatible: IE=Edge
 3 Etag: \"f7b0b4dea015140f3b5ad90c3a392bef\"
 4 Connection: Keep-Alive
 5 Content-Type: text/html; charset=utf-8
 6 Date: Sun, 12 Jun 2011 03:44:22 GMT
 7 Server: WEBrick/1.3.1 (Ruby/1.8.7/2009-06-12)
 8 X-Runtime: 0.235347
 9 Content-Length: 5520
10 Cache-Control: max-age=0, private, must-revalidate
已缓存:
$wget --server-response http://localhost:3000/about

Resolving localhost... 127.0.0.1
Connecting to localhost[127.0.0.1]:3000... connected.
HTTP request sent, awaiting response... 
 1 HTTP/1.1 200 OK
 2 Last-Modified: Sun, 12 Jun 2011 03:34:42 GMT
 3 Connection: Keep-Alive
 4 Content-Type: text/html
 5 Date: Sun, 12 Jun 2011 03:39:53 GMT
 6 Server: WEBrick/1.3.1 (Ruby/1.8.7/2009-06-12)
 7 Content-Length: 5783
结果,页面以ISO-8859-1显示,并且出现一堆乱码。有谁知道我如何防止这种不良后果?谢谢。     
已邀请:
        解决方案将取决于所使用的服务器。 使用页面缓存时,服务器直接读取服务器,因此rails堆栈不会向服务器提供编码信息。然后应用服务器默认设置。 如果您对乘客使用apache,请添加配置:
AddDefaultCharset UTF-8
如果您需要特定的字符集,请使用http://www.philsergi.com/2007/06/rails-page-caching-and-mime-types.html中的解决方案
<LocationMatch \\/(rss)\\/?>
    ForceType text/xml;charset=utf-8
</LocationMatch>
<LocationMatch \\/(ical)\\/?>
    ForceType text/calendar;charset=utf-8
</LocationMatch>
    

要回复问题请先登录注册