使用HttpMemcModule遇到了问题

58 views
Skip to first unread message

haoyun

unread,
Feb 19, 2013, 5:44:34 AM2/19/13
to open...@googlegroups.com
大家好!
我在使用HttpMemcModule模块时遇到了一个问题,我用curl在linux终端下访问可以得到数据,但是在浏览器访问却提示我下载,我以前遇到过这样的问题,我就按照以前的做法把default_type设置成text/plain在location里,重启nginx,无效,还是提示下载,我在http段设置default_type text/plain;还是不行,请帮我看下是什么问题?
os:RHEL5 update 4 x86_64
ngx_openresty-1.2.4.14
memcached-1.4.15
curl 7.15.5
chrome 24.01312.57 m

配置如下:
worker_processes 1;
error_log logs/error.log debug;
events {
        worker_connections 1024;
}
http {
        include mime.types;
        #default_type application/octet-stream;
        default_type text/plain;
        sendfile on;
        keepalive_timeout 65;
        upstream memcached {
                server 127.0.0.1:11211;
        }
        server {
                listen 80;
                server_name localhost;
                root html;
                index index.html index.htm;
                location = /memcached-status {
                        set $memc_cmd stats;
                        memc_pass memcached;
                }
                location / {
                        set $memc_cmd $arg_cmd;
                        set $memc_key $arg_key;
                        set $memc_value $arg_val;
                        set $memc_flags $arg_flags;
                        set $memc_exptime $arg_exptime;

                        memc_cmds_allowed get set add incr delete flush_all;
                        memc_flags_to_last_modified on;

                        memc_pass memcached;
                }
                error_page 500 502 503 504 /50x.html;
                location = /50x.html {
                        root html;
                }
        }
}
这个是nginx.conf配置
我在linux终端中用下面方法测试:
[root@localhost logs]# curl 'localhost/?cmd=get&key=1'
10
但是用chrome浏览器就是提示下载


来自网易手机号码邮箱了解更多

agentzh

unread,
Feb 19, 2013, 3:02:38 PM2/19/13
to open...@googlegroups.com
Hello!

2013/2/19 haoyun:
> 我在使用HttpMemcModule模块时遇到了一个问题,我用curl在linux终端下访问可以得到数据,但是在浏览器访问却提示我下载,我以前遇到过这样的问题,我就按照以前的做法把default_type设置成text/plain在location里,重启nginx,无效,还是提示下载,我在http段设置default_type
> text/plain;还是不行,请帮我看下是什么问题?

浏览器中提示下载一般是因为 Content-Type 响应头中指示的不是可以直接显示的类型。确实可以通过 default_type 这样的配置指令进行控制。

[...]
> 这个是nginx.conf配置
> 我在linux终端中用下面方法测试:
> [root@localhost logs]# curl 'localhost/?cmd=get&key=1'
> 10

你能改用 curl -i 'localhost/?cmd=get&key=1' 命令同时查看响应头吗?这里最重要的是查看 Content-Type 响应头 :)

> 但是用chrome浏览器就是提示下载
>

另外,记得测试前总是清空你的浏览器缓存 ;) 否则经常会被误导。

Best regards,
-agentzh

azure wang

unread,
Feb 19, 2013, 7:53:34 PM2/19/13
to open...@googlegroups.com

curl -i  xxxxx 看看header

--
--
邮件自: 列表“openresty”,专用于技术讨论!
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
详情: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
建议: 提问的智慧 http://wiki.woodpecker.org.cn/moin/AskForHelp
教程: http://agentzh.org/misc/nginx/agentzh-nginx-tutorials-zhcn.html
 
---
您收到此邮件是因为您订阅了 Google 网上论坛的“openresty”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到 openresty+...@googlegroups.com
要查看更多选项,请访问 https://groups.google.com/groups/opt_out。
 
 

haoyun

unread,
Feb 19, 2013, 10:44:10 PM2/19/13
to open...@googlegroups.com
这个问题解决了,确实是浏览器缓存问题,谢谢各位了^_^!
 logs]# curl 'localhost/?cmd=get&key=1'
>> 10
>
>你能改用 curl -i 'localhost/?cmd=get&key=1' 命令同时查看响应头吗?这里最重要的是查看 Content-Type 响应头 :)
>
>> 但是用chrome浏览器就是提示下载
>>
>
>另外,记得测试前总是清空你的浏览器缓存 ;) 否则经常会被误导。
>
>Best regards,
>-agentzh
>
>-- 
>-- 
>邮件自: 列表“openresty”,专用于技术讨论!
>发言: 请发邮件到 open...@googlegroups.com
>退订: 请发邮件至 openresty+unsub...@googlegroups.com
>
>--- 
>您收到此邮件是因为您订阅了 Google 网上论坛的“openresty”论坛。
>要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到 openresty+unsub...@googlegroups.com。
>要查看更多选项,请访问 https://groups.google.com/groups/opt_out。
>
>


来自网易手机号码邮箱了解更多
Reply all
Reply to author
Forward
0 new messages