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对响应的任何压缩操作。

相关推荐
爱笑的眼睛1131 分钟前
自动机器学习组件的深度解析:超越AutoML框架的底层架构
java·人工智能·python·ai
⑩-39 分钟前
简单业务异常类
java
乘风!41 分钟前
NSSM启动tomcat部署Java程序
java·服务器·后端·tomcat
BBB努力学习程序设计1 小时前
Java 21虚拟线程与平台线程:JVM层面的深度对比与实现原理
java
代码无疆1 小时前
学点java字节码更易于理解一些特殊的java语法效果
java·后端
BBB努力学习程序设计1 小时前
Java 8日期时间API完全指南:告别Date和Calendar的混乱时代
java
不能只会打代码1 小时前
力扣--3433. 统计用户被提及情况
java·算法·leetcode·力扣
知青先生1 小时前
E9项目调试方式
java·ide
本地运行没问题1 小时前
从零散编译到一键打包:Maven如何重塑Java构建流程
java
10km1 小时前
java:延迟加载实现方案对比:双重检查锁定 vs 原子化条件更新
java·延迟加载·双重检查锁定