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

前端之家收集整理的这篇文章主要介绍了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)
    }
}

原文链接:https://www.f2er.com/nginx/435415.html

猜你在找的Nginx相关文章