让nginx等待x秒,然后返回页面

时间:2019-12-29 23:07:13

标签: nginx nginx-location

我希望给定的页面在x秒后加载,例如,当有人访问URL“ https://example.com/examplelocation”时,浏览器将尝试加载页面几秒钟,然后nginx将返回其HTTP OK,页面正文,这可能吗? 伪代码:

location ~ ^/examplelocation/ {
  # wait some time and then send the response
}

1 个答案:

答案 0 :(得分:1)

我知道echo module,它可以通过使用echo_sleep将响应延迟给定的秒数。

location / {
    echo_sleep 1;
    echo_exec @test;
}
location @test {
    echo $echo_request_uri;
}

让我知道是否有任何查询。