小编Kev*_* G.的帖子

如何使用 proxy_pass 和 if_modified_since 让 nginx 返回 304-Not Modified

我看到有迹象表明这应该有效,所以我希望我错过了一些简单的事情。

我们有两个 nginx“服务器”,前面有一个 proxy_pass 缓存,后面有一个 SSI 服务器。如果我在请求中使用 If-Modified-Since 标头直接访问 SSI 服务器,它将返回 304-Not Modified 响应,这正是我们想要的。但我无法让 proxy_pass 缓存服务器返回 304-Not Modified 任何内容。

我应该能够让 proxy_pass 返回 304-Not Modified 吗?还有其他人可以使用您可以分享的配置吗?或者你能发现我的配置中的问题吗?

# this is the cache in front
server {
    listen 8096;    
    server_name _;
    proxy_buffering on;

    location /assets {
        proxy_pass http://localhost:8095;
        proxy_cache   my-cache;
        proxy_cache_valid  200s;
        if_modified_since before;
    }       
}

server {
    listen 8095;
    server_name _;
    root /var/www/;
    location / { deny all; }

    location /assets {}
        ssi on; # on or off doesn't make a …
Run Code Online (Sandbox Code Playgroud)

nginx

5
推荐指数
1
解决办法
7148
查看次数

标签 统计

nginx ×1