pandyl 发表于 2012-7-13 03:04:14

求助军哥:如何修改nginx默认设置的HTTP-header

装了lnmp0.9一键安装宝,php文件默认发送的http-header是这样的

(Status-Line)    HTTP/1.1 200 OK
Server    nginx/1.0.15
Date    Thu, 12 Jul 2012 18:21:56 GMT
Content-Type    text/html; charset=utf-8
Transfer-Encoding    chunked
Connection    keep-alive
X-Powered-By    PHP/5.2.17p1
Expires    Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control    no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma    no-cache
Content-Encoding    gzip
Vary    Accept-Encoding

我想去掉
Expires    Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control    no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma    no-cache
这三行,应该如何操作呢?
我的程序使用的伪静态,网页启用页面缓存的,所以在一段时间内(比如1天),网页页面是不变的。
我用 header 函数发送 Last-Modified 和 Etag
http头会增加这两句
Last-Modified    Thu,12 Jul 2012 00:00:00 GMT
Etag    "099930e0857f96c46286c380024d8d58"

但是由于默认发送的 Cache-Control    no-store
浏览器并不会缓存网页
请问如何设置NGINX默认发送的HTTP头
知道的教下,万分感谢

[ 本帖最后由 pandyl 于 2012-7-13 03:06 编辑 ]

licess 发表于 2012-7-13 08:49:38

http://wiki.nginx.org/HttpHeadersModule

pandyl 发表于 2012-7-13 16:53:26

修改 nginx.conf?
我在其中加入了 PHP的 expires

expires 24h ;
重启 nginx
但是仍然是原来的HTTP头,没有改变

pandyl 发表于 2012-7-13 17:33:45

问题已经解决,
原来相关HTTP头是PHP发送的,不是nginx发送的
原因是程序使用了session,而php.ini中默认设置是,带有session的不缓存,
session.cache_fileter()= nocahce ,降该值改成 none,就不会发送这个http头了
页: [1]
查看完整版本: 求助军哥:如何修改nginx默认设置的HTTP-header