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

我们最近发现了有关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)
    }
}

相关文章

Nginx (engine x) 是一个高性能的HTTP和反向代理服务,也是一...
本地项目配置 1 复制 luffy/settings/dev.py为prop.py 修改l...
nginx不仅可以隐藏版本信息,还支持自定义web服务器信息 先看...
一 、此次漏洞分析 1 nginx HTTP/2漏洞 [nginx-announce] ng...
###进入nginx 目录cd /usr/local/nginx###递归显示 2 级目录...
在cmd命令窗口输入下面命令进行查看 tasklist /fi "ima...