最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

Nginx缓存整个节点快速应用程序

IT培训 admin 14浏览 0评论

Nginx缓存整个节点/快速应用程序

Jolly Goody早上好!我正在尝试完全缓存Node / Express应用程序。该站点很少更改,因此我很想拥有一个漂亮的字符串缓存机制。

[设置看起来如何将应用程序(html,css,img,...)完全放入Nginx缓存(公共缓存),持续5分钟,因此该页面从Nginx缓存“静态”提供,而Express-应用程序无响应吗?

我觉得这不是正确的设置:

proxy_cache_path /cache levels=1:2 keys_zone=my_cache:10m max_size=10g
                 inactive=60m use_temp_path=off;
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        location ^~ / {
                proxy_cache my_cache;
                proxy_pass http://localhost:3030;
                }
}
回答如下:
proxy_cache_path /cache levels=1:2 keys_zone=my_cache:100m max_size=10g inactive=5m use_temp_path=off;
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        location ^~ / {
                proxy_cache my_cache;
                proxy_pass http://localhost:3030;                
                # cache all requests of any type for 5m
                proxy_cache_methods HEAD GET POST;
                proxy_cache_valid any 5m;
                expires 5m;
                # default proxy cache key can be adjusted
                proxy_cache_key $scheme$proxy_host$request_uri;
                # set header - Host & Forwarded-For
                proxy_set_header Host $host;
                proxy_set_header Forwarded-For $proxy_add_x_forwarded_for;
                # cache on first use
                proxy_cache_min_uses 0;
                }
}

Module ngx_http_proxy_module

  • expire5分钟
  • 所有内容为有效,持续时间为[[5分钟] >>
  • 5分钟
  • 后,清除非活动缓存

    使用nginx news保持最新状态>>

Nginx缓存整个节点/快速应用程序

Jolly Goody早上好!我正在尝试完全缓存Node / Express应用程序。该站点很少更改,因此我很想拥有一个漂亮的字符串缓存机制。

[设置看起来如何将应用程序(html,css,img,...)完全放入Nginx缓存(公共缓存),持续5分钟,因此该页面从Nginx缓存“静态”提供,而Express-应用程序无响应吗?

我觉得这不是正确的设置:

proxy_cache_path /cache levels=1:2 keys_zone=my_cache:10m max_size=10g
                 inactive=60m use_temp_path=off;
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        location ^~ / {
                proxy_cache my_cache;
                proxy_pass http://localhost:3030;
                }
}
回答如下:
proxy_cache_path /cache levels=1:2 keys_zone=my_cache:100m max_size=10g inactive=5m use_temp_path=off;
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        location ^~ / {
                proxy_cache my_cache;
                proxy_pass http://localhost:3030;                
                # cache all requests of any type for 5m
                proxy_cache_methods HEAD GET POST;
                proxy_cache_valid any 5m;
                expires 5m;
                # default proxy cache key can be adjusted
                proxy_cache_key $scheme$proxy_host$request_uri;
                # set header - Host & Forwarded-For
                proxy_set_header Host $host;
                proxy_set_header Forwarded-For $proxy_add_x_forwarded_for;
                # cache on first use
                proxy_cache_min_uses 0;
                }
}

Module ngx_http_proxy_module

  • expire5分钟
  • 所有内容为有效,持续时间为[[5分钟] >>
  • 5分钟
  • 后,清除非活动缓存

    使用nginx news保持最新状态>>

发布评论

评论列表 (0)

  1. 暂无评论