ruby on rails - Why does nginx + memcache corrupt my response body? -
i'm caching web pages in memcache. when read page directly cache, page formed ...
!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en"-:--     0 "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">    <head>     <meta http-equiv="content-type" content="text/html;charset=utf-8" />   but when use browser or curl read nginx (version 0.8.50), looks response headers ending in body of response ...
     �{         "    etag"'"16bb9f51667d334aa4e7663ca28d308a""x-runtime177"content-type"text/html; charset=utf-8"content-length"5428"set-cookie""cache-control"(private, max-age=0, must-revalidate"4<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en"     "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">   
 nginx config pretty simple ...
     set $memcached_key $cookie__app_session$uri;      memcached_pass     localhost:11211;      default_type       text/html;          error_page         404 502 /fallback$uri;   does have idea why response corrupt?
do! stupid developer problem!
 there 2 mistakes
(a) storing response header , body in memcache, adding headers in nginx rule. storing response body in memcache removed bulk of problems
(b) storing response in ruby's marshal format (the default setting in memcache-client) - reading contents of memcache using simple ruby client hiding fact format not directly usable nginx.
hope helps sometime!
chris
Comments
Post a Comment