启用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显示,并且出现一堆乱码。有谁知道我如何防止这种不良后果?谢谢。
没有找到相关结果
已邀请:
1 个回复
久坡
如果您需要特定的字符集,请使用http://www.philsergi.com/2007/06/rails-page-caching-and-mime-types.html中的解决方案