apache - Varnish绕过大文件

标签 apache caching varnish varnish-vcl

我在我的 Apache Web 服务器上安装了默认设置的 Varnish。 Apache 列表到端口 8080,Varnish 列表到 80。

我在网站上几乎没有大小为 100MB、500MB 和 1GB 的可下载文件

1GB 不工作,当你点击它时它会说不可用页面或连接被服务器关闭。其他两个工作正常,但我不确定这是否是下载它们的正确方法。

我如何让 Varnish 绕过这些文件并直接从 Web 服务器获取它们?

谢谢。

最佳答案

这可以通过检查后端答案中的 Content-Length 来完成,如果它大于某个大小,则用一些标记标记它并重新启动请求交易

例如,Content-Length >=10,000,00 的文件应该通过管道传输:

sub vcl_fetch {
..
  if ( beresp.http.Content-Length ~ "[0-9]{8,}" ) {
     set req.http.x-pipe-mark = "1";
     return(restart);
  }
..
}

然后我们返回检查请求接收和解析。 在这里我们可以检查我们的标记并执行 pipe

sub vcl_recv {
..
  if (req.http.x-pipe-mark && req.restarts > 0) {
    return(pipe);
  }
..
}

关于apache - Varnish绕过大文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23065255/

相关文章:

python - Django、mod_wsgi、 Apache : Internal server error

python - 重置 lru_cache 中的缓存

caching - 避免CSRF token

ruby-on-rails - '变化 : If-None-Match' to cache mobile and desktop requests separately

amazon-web-services - AWS ELB 后面的两个 Varnish 服务器之间的一致性

mysql - 在 Windows Server 上配置 wamp 服务器?

Apache Wamp [错误] (20024)给定路径格式错误或包含无效字符

apache - Htaccess 将 '/' 放在 url 末尾时

caching - 在获取新数据时在 react-native 应用程序上使用中继缓存数据

php 内容从未被浏览器缓存?