加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

Nginx反向代理:post_action如果代理缓存命中 – Possbile?

发布时间:2020-12-13 21:17:55 所属栏目:Nginx 来源:网络整理
导读:我们最近发现了有关nginxes post_action 的信息. 我们想知道如果进行代理缓存命中,有一种方法可以使用该指令吗? 我们希望的流程如下: 1) User request comes in2) If cache HIT goto A / If cache MISS goto BA) 1) Serve Cached ResultA) 2) post_action

我们最近发现了有关nginxes post_action的信息.

我们想知道如果进行代理缓存命中,有一种方法可以使用该指令吗?

我们希望的流程如下:

1) User request comes in
2) If cache HIT goto A / If cache MISS goto B

A) 1) Serve Cached Result
A) 2) post_action to another url on the backend

B) 1) Server request from backend
B) 2) Store result from backend

如果可以通过post_action或任何其他方法获得任何想法?

这背后的原因如下:

我们本质上希望在显示缓存内容时修改用户会话(php,但相同的概念可以应用于大多数服务器端语言).这将大大增加我们处理的可缓存请求的数量,因为这些请求仅写入会话而不是从会话中读取.

谢谢!

最佳答案
如果你还没有解决它,那么这是一个通过你的要求的示例配置:

server {
    listen 80;
    server_name img1.example;
    root /var/www/images;
    location / { // Users request comes in
        try_files $uri @proxy; // If cache HIT goto A (show) / If cache MISS goto B (@proxy),server cached result
        post_action /url.php; // post_action to another url on the backend
    }

    location @proxy {
        proxy_pass http://static.exmaple; // Server request from backend
        proxy_store /var/www/images$uri; // Store result from backend (cache)
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读