web server apache tomcat11-25-Advanced IO and Tomcat

前言

整理这个官方翻译的系列,原因是网上大部分的 tomcat 版本比较旧,此版本为 v11 最新的版本。

开源项目

从零手写实现 tomcat minicat 别称【嗅虎】心有猛虎,轻嗅蔷薇。

系列文章

web server apache tomcat11-01-官方文档入门介绍

web server apache tomcat11-02-setup 启动

web server apache tomcat11-03-deploy 如何部署

web server apache tomcat11-04-manager 如何管理?

web server apache tomcat11-06-Host Manager App -- Text Interface

web server apache tomcat11-07-Realm Configuration

web server apache tomcat11-08-JNDI Resources

web server apache tomcat11-09-JNDI Datasource

web server apache tomcat11-10-Class Loader

web server apache tomcat11-11-Jasper 2 JSP Engine

web server apache tomcat11-12-SSL/TLS Configuration

web server apache tomcat11-13-SSI

web server apache tomcat11-14-CGI

web server apache tomcat11-15-proxy

web server apache tomcat11-16-mbean

web server apache tomcat11-17-default-servlet

web server apache tomcat11-18-clusting 集群

web server apache tomcat11-19-load balance 负载均衡

web server apache tomcat11-20-connectors 连接器

web server apache tomcat11-21-monitor and management 监控与管理

web server apache tomcat11-22-logging 日志

web server apache tomcat11-23-APR

web server apache tomcat11-24-Virtual Hosting and Tomcat

web server apache tomcat11-25-Advanced IO and Tomcat

web server apache tomcat11-26-maven jars

web server apache tomcat11-27-Security Considerations

web server apache tomcat11-28-Windows Service

web server apache tomcat11-29-Windows Authentication

web server apache tomcat11-30-The Tomcat JDBC Connection Pool

web server apache tomcat11-31-websocket

web server apache tomcat11-32-rewrite

web server apache tomcat11-33-CDI

web server apache tomcat11-34-Ahead of Time compilation support

介绍

重要提示:使用这些功能需要使用HTTP连接器。AJP连接器不支持它们。

异步写入

当使用HTTP连接器时,Tomcat支持使用sendfile发送大型静态文件。这些写操作在系统负载增加时会以最有效的方式异步执行。与使用阻塞写操作发送大型响应不同,可以将内容写入静态文件,并使用sendfile代码进行写入。缓存阀门可以利用这一点,将响应数据缓存到文件中,而不是将其存储在内存中。如果请求属性 org.apache.tomcat.sendfile.support 被设置为 Boolean.TRUE,则可以使用sendfile支持。

任何Servlet都可以通过设置适当的请求属性来指示Tomcat执行sendfile调用。还需要正确设置响应的内容长度。当使用sendfile时,最好确保请求或响应都没有被包装,因为响应主体将由连接器自身稍后发送,无法进行过滤。除了设置所需的3个请求属性之外,Servlet不应发送任何响应数据,但可以使用任何导致修改响应标头的方法(比如设置cookies)。

  • org.apache.tomcat.sendfile.filename:将作为String发送的文件的规范文件名
  • org.apache.tomcat.sendfile.start:作为Long的起始偏移量
  • org.apache.tomcat.sendfile.end:作为Long的结束偏移量

除了设置这些参数之外,还需要设置content-length头。Tomcat不会为您执行此操作,因为您可能已经将数据写入输出流。

请注意,使用sendfile将禁用Tomcat对响应的任何压缩操作。

相关推荐
Java水解几秒前
Go基础:Go语言中 Goroutine 和 Channel 的声明与使用
java·后端·面试
Chan1610 分钟前
流量安全优化:基于 Nacos 和 BloomFilter 实现动态IP黑名单过滤
java·spring boot·后端·spring·nacos·idea·bloomfilter
小小爱大王1 小时前
AI 编码效率提升 10 倍的秘密:Prompt 工程 + 工具链集成实战
java·javascript·人工智能
神龙斗士2402 小时前
继承和组合
java·开发语言
小蒜学长2 小时前
springboot基于JAVA的二手书籍交易系统的设计与实现(代码+数据库+LW)
java·数据库·spring boot·后端
菜鸟plus+2 小时前
Semaphore
java
小梁努力敲代码2 小时前
java数据结构--LinkedList与链表
java·数据结构·链表
それども2 小时前
IDEA Gradle并行编译内存溢出问题
java·ide·gradle·intellij-idea
滑水滑成滑头3 小时前
**发散创新:探索零信任网络下的安全编程实践**随着信息技术的飞速发展,网络安全问题日益凸显。传统的网络安全防护方式已难以
java·网络·python·安全·web安全