Nginx REST API缓存

问题描述 投票:0回答:1

我创建了一个Spring Boot项目。我必须缓存一个Rest API调用:

获取localhost:8080 / parts

为此,我使用了nginx。但这是行不通的:每次我调用API时,该调用都会进入后端。我的配置文件如下。

/ usr / local / etc / nginx / nginx.conf

http {
    include            mime.types;
    default_type       application/octet-stream;
    sendfile           on;
    keepalive_timeout  65;

    error_page   500 502 503 504  /50x.html;

    proxy_cache_path /var/log/oms levels=1:2 keys_zone=webcache:10m inactive=1d max_size=2000m;
    proxy_cache_min_uses 1;

    #upstream backend_server {
    # server localhost:8080;    
    #}

    server {
        listen 80;
        server_name localhost;

        location /parts {
            proxy_pass  http://localhost:8080/parts;
            proxy_cache webcache;
        }

        #location /{
        #    proxy_pass http://localhost:8080;
        #    proxy_cache webcache;
        #}
    }

    include servers/*;
}
rest caching nginx spring-boot
1个回答
1
投票

我知道这个问题已经存在一年多了。但是您是否有用于缓存API调用的任何解决方案?

© www.soinside.com 2019 - 2024. All rights reserved.