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

相关推荐
Otaku love travel21 分钟前
老系统改造增加初始化,自动化数据源配置(tomcat+jsp+springmvc)
java·tomcat·初始化·动态数据源
DKPT35 分钟前
Java设计模式之行为型模式(责任链模式)介绍与说明
java·笔记·学习·观察者模式·设计模式
L_autinue_Star1 小时前
手写vector容器:C++模板实战指南(从0到1掌握泛型编程)
java·c语言·开发语言·c++·学习·stl
晨岳1 小时前
CentOS 安装 JDK+ NGINX+ Tomcat + Redis + MySQL搭建项目环境
java·redis·mysql·nginx·centos·tomcat
执笔诉情殇〆1 小时前
前后端分离(java) 和 Nginx在服务器上的完整部署方案(redis、minio)
java·服务器·redis·nginx·minio
YuTaoShao1 小时前
【LeetCode 热题 100】24. 两两交换链表中的节点——(解法一)迭代+哨兵
java·算法·leetcode·链表
程序员的世界你不懂2 小时前
(20)Java+Playwright自动化测试- 操作鼠标拖拽 - 上篇
java·python·计算机外设
AI360labs_atyun2 小时前
Java在AI时代的演进与应用:一个务实的视角
java·开发语言·人工智能·科技·学习·ai
不像程序员的程序媛3 小时前
redis的一些疑问
java·redis·mybatis
知其然亦知其所以然3 小时前
Java 面试高频题:GC 到底回收了什么、怎么回收、啥时候回收?
java·后端·面试