# CalDAV

**CalDAV**（Calendaring Extensions to WebDAV，即 WebDAV 的日历扩展）是一项互联网标准，由 RFC 4791 定义，于 2007 年 3 月发布，规定了一种通过 HTTP 访问、管理和共享日历与日程安排信息的标准方式。它扩展了 WebDAV（而 WebDAV 本身又是对 HTTP 的扩展），以 iCalendar 格式传输日历数据，因此单个 CalDAV 客户端无需针对不同厂商编写代码，就能在任何符合规范的服务器上读写事件。<sup>[1](https://www.rfc-editor.org/info/rfc4791/)</sup><sup> • </sup><sup>[2](https://cli.nylas.com/guides/caldav-explained)</sup>

| 关键事实 | 详情 |
|---|---|
| 核心规范 | RFC 4791，2007 年 3 月发布；定义了 CalDAV 的“calendar-access”特性<sup>[1](https://www.rfc-editor.org/info/rfc4791/)</sup> |
| 数据模型 | 日历是一个 WebDAV 集合；每个事件、待办事项、日记条目或其他日历组件都是一个“日历对象资源”，以 iCalendar 对象的形式存储<sup>[1](https://www.rfc-editor.org/info/rfc4791/)</sup> |
| 能力发现 | 支持 CalDAV 的服务器必须在 OPTIONS 请求的 DAV 响应头中包含“calendar-access”<sup>[1](https://www.rfc-editor.org/info/rfc4791/)</sup> |
| 日程安排 | RFC 6638（2012 年 6 月）增加了“calendar-auto-schedule”，由服务器自动发送和处理日程安排消息<sup>[3](https://www.rfc-editor.org/info/rfc6638/)</sup> |
| 同步 | RFC 6578（2012 年 3 月）定义了带不透明同步令牌的 sync-collection 报告，使客户端只获取新增、变更或删除的条目<sup>[4](https://www.rfc-editor.org/info/rfc6578/)</sup> |
| 服务发现 | RFC 6764（2013 年 2 月）将“.well-known”URI“caldav”和“carddav”注册为初始上下文路径，由服务器将客户端重定向到真实端点<sup>[5](https://www.rfc-editor.org/info/rfc6764/)</sup> |
| 推送 | CalDAV 没有标准的变更通知机制；要保持最新状态，只能通过同步令牌或 ETag 比较进行轮询<sup>[2](https://cli.nylas.com/guides/caldav-explained)</sup> |

## 数据模型

CalDAV 建立在 WebDAV 坚实的数据模型之上。CalDAV 日历被建模为具有既定结构的 WebDAV 集合，每个日历集合都包含若干资源作为其直接子项，这些资源代表日历对象。每个代表事件、待办事项、日记条目或其他日历组件的资源称为“日历对象资源”。每个日历对象资源和每个日历集合都可以单独加锁，并可以携带各自的 WebDAV 属性。<sup>[1](https://www.rfc-editor.org/info/rfc4791/)</sup>

日历集合可以在为用户账户进行配置时自动创建，也可以通过 MKCALENDAR 方法显式创建，用户可以用它创建额外的日历，例如足球赛程或团队共享事件日历。<sup>[1](https://www.rfc-editor.org/info/rfc4791/)</sup> 带有一个被覆盖实例的重复事件存储为单个日历对象资源，其中同时包含重复规则和被覆盖的组件。<sup>[1](https://www.rfc-editor.org/info/rfc4791/)</sup>

**服务器要求。** 支持 calendar-access 特性的服务器，对于任何支持日历属性、报告、方法或权限的资源，都必须在 OPTIONS 请求的 DAV 响应头中包含“calendar-access”；该值表示支持规范中所有强制性要求。服务器应当支持 MKCALENDAR，并且由于离线功能对日历应用比对许多其他 WebDAV 应用更为重要，CalDAV 服务器必须支持 ETag。<sup>[1](https://www.rfc-editor.org/info/rfc4791/)</sup><sup> • </sup><sup>[6](https://greenbytes.de/tech/webdav/rfc4791.pdf)</sup>

## 客户端如何工作

CalDAV 客户端事先并不知道日历的 URL，而是分步骤发现它。约定从 `/.well-known/caldav` 开始，服务器将其重定向到自己的主体 URL；客户端先用 PROPFIND 查询 `current-user-principal`，再查询 `calendar-home-set`，从而逐步找到存放其日历的集合，之后便可以列出事件。<sup>[2](https://cli.nylas.com/guides/caldav-explained)</sup> RFC 6764 对此作了形式化规定：“.well-known”URI 只是一个上下文路径，服务器必须使用 301、303 或 307 响应等 HTTP 机制重定向对该 URI 的请求，且服务器不得将实际服务端点设在“.well-known”URI 本身。<sup>[5](https://www.rfc-editor.org/info/rfc6764/)</sup>

读写操作大量依赖 XML。客户端需要构造 PROPFIND 和 `calendar-query` REPORT 请求体，并解析多状态 207 响应，其中只要缺少一个命名空间就可能导致请求失败；事件以原始 iCalendar VEVENT 文本返回，由客户端自行解码。写入使用 PUT 上传 iCalendar（`.ics`）文件，每个事件一个资源。<sup>[2](https://cli.nylas.com/guides/caldav-explained)</sup><sup> • </sup><sup>[7](https://developer.nylas.com/docs/cookbook/calendar/caldav-vs-calendar-api/)</sup> 由于客户端通常以跨越有限时间区间的视图呈现数据，规范建议使用 `calendar-query` REPORT 结合 `CALDAV:time-range` 元素来检索组件，将返回的组件限制为当前视图所需的那些。<sup>[6](https://greenbytes.de/tech/webdav/rfc4791.pdf)</sup>

**身份验证。** CalDAV 通过按用户划分范围的 HTTP 基本认证进行身份验证，没有 OAuth 流程，也没有集中的开发者控制台。iCloud 要求每个用户在 Apple ID 设置中生成一个 16 个字符的应用专用密码，因为普通账户密码无法通过 CalDAV 端点的验证；Fastmail 也以同样方式发放按应用划分的密码。由于没有令牌刷新流程，被撤销的密码会在下一次同步时静默失败。<sup>[7](https://developer.nylas.com/docs/cookbook/calendar/caldav-vs-calendar-api/)</sup>

## 同步与日程安排

CalDAV 本身没有推送机制，因此客户端通过轮询保持最新状态。RFC 6578《WebDAV 集合同步》定义了标准做法：每次运行 sync-collection 报告时，服务器都会给客户端一个同步令牌；当客户端之后出示该令牌时，服务器只返回自令牌生成以来新增、变更或删除的条目，并附带一个新令牌。首次同步使用空令牌请求完整列表。客户端将令牌视为不透明字符串，但它必须是合法的 URI。<sup>[4](https://www.rfc-editor.org/info/rfc6578/)</sup> 一个相关的约定是日历集合实体标签（ctag），当日历中任何内容发生变化时它就会改变，使客户端能够快速判断自己无需同步任何事件。<sup>[8](https://developers.google.cn/workspace/calendar/caldav/v2/guide?hl=en)</sup>

RFC 6638《CalDAV 日程安排扩展》增加了“calendar-auto-schedule”特性。它利用 iTIP（RFC 5546）的日程安排方法，让日历用户能够安排、重新安排、响应请求、取消组件以及查询忙闲时间。这种设计称为“隐式日程安排”：服务器负责发送日程安排消息并处理传入的消息，因此客户端对日历组件的普通创建、修改或删除就足以触发向其他日历用户投递必要的消息。该规范处理的是单一系统内用户之间的日程安排，但通过 iMIP（RFC 6047）与外部用户交换消息也是兼容的。<sup>[3](https://www.rfc-editor.org/info/rfc6638/)</sup>

## 扩展

若干 RFC 对基础协议进行了扩展。RFC 7809（2016 年 3 月）《通过引用指定时区》允许客户端和服务器交换 iCalendar 数据时不发送完整的 VTIMEZONE 组件——这些组件可能比使用它们的事件还要大；客户端将 CalDAV-Timezones 请求头设为“F”，即可对可从公布的时区分发服务器获取的标识符省略时区数据，并可在时间范围查询中传入 `CALDAV:timezone-id` 元素代替完整组件。<sup>[9](https://www.rfc-editor.org/info/rfc7809/)</sup> RFC 7953（2016 年 8 月）《日历可用性》增加了在 DAV 响应头中通告的“calendar-availability”特性，支持用 VAVAILABILITY 组件发布可用时间。<sup>[10](https://www.rfc-editor.org/info/rfc7953/)</sup> RFC 8607（2019 年 6 月）涉及受管附件。IETF 日历扩展（calext）工作组的章程是维护和扩展这些规范，起点包括 CalDAV（RFC 4791）、iCalendar（RFC 5545）、iTIP（RFC 5546）、iMIP（RFC 6047）、vCard（RFC 6350）、CardDAV（RFC 6352）、JSCalendar（RFC 8984）和 JSContact，预计扩展将保持向后兼容。<sup>[11](https://datatracker.ietf.org/wg/calext/about/)</sup>

## 采用情况与局限

CalDAV 是 iCloud、Fastmail、Yahoo 以及许多自托管日历背后的协议；iCloud 和 Fastmail 将其作为唯一的程序化日历接口对外提供，上面没有 JSON 或 OAuth 层。Google 提供了 CalDAV 接口，但引导开发者使用自家的 API，且其实现并不完整：它支持 REPORT 方法及除 `free-busy-query` 之外的所有报告，不支持 MKCALENDAR，不支持 VTODO 或 VJOURNAL 数据，不支持 WebDAV 访问控制，并要求客户端在初始同步后改用 RFC 6578 同步。<sup>[2](https://cli.nylas.com/guides/caldav-explained)</sup><sup> • </sup><sup>[7](https://developer.nylas.com/docs/cookbook/calendar/caldav-vs-calendar-api/)</sup><sup> • </sup><sup>[8](https://developers.google.cn/workspace/calendar/caldav/v2/guide?hl=en)</sup>

由于它是一项标准而非厂商 API，同一个客户端无需针对不同厂商编写代码，就能与 Apple、Fastmail 以及自托管的 Radicale 服务器通信。代价在于：这是一套 2007 年的设计，建立在大多数开发者从未直接接触过的 XML 请求体和 HTTP 方法之上，再加上各服务器的怪癖：现实中的服务器对 RFC 的遵循程度参差不齐，尤其是在服务器端时间范围查询和重复展开方面。<sup>[2](https://cli.nylas.com/guides/caldav-explained)</sup><sup> • </sup><sup>[12](https://github.com/allenporter/icaldav/blob/main/DESIGN.md)</sup>

按事件划分的数据模型对共享日历来说是一个实际优势。

## 历史

早在 1997 或 1998 年，IETF CALSCH 工作组就讨论过以 HTTP 和 WebDAV 作为日历访问协议基础的想法。有几家公司实现了使用 HTTP 上传和下载 iCalendar 对象、使用 WebDAV 列出资源的日历访问协议，但这些实现无法互操作，因为关于将日历数据建模为 WebDAV 资源的许多决策都悬而未决。RFC 4791 提出了一种在 WebDAV 中建模日历数据的方式，并附加了使其成为可互操作协议的特性。<sup>[1](https://www.rfc-editor.org/info/rfc4791/)</sup> CalDAV 客户端与服务器之间的互操作性测试早在 2005 年 1 月就已在进行，当时该标准还是草案，在一次 CalConnect 活动中测试了两台服务器和三个客户端应用。<sup>[13](https://standards.calconnect.org/cc/cc-a0502-2005.html)</sup>

## References

1. [RFC 4791: Calendaring Extensions to WebDAV (CalDAV), RFC Editor](https://www.rfc-editor.org/info/rfc4791/)
2. [CalDAV Explained: Protocol and Pitfalls, Nylas CLI](https://cli.nylas.com/guides/caldav-explained)
3. [RFC 6638: Scheduling Extensions to CalDAV, RFC Editor](https://www.rfc-editor.org/info/rfc6638/)
4. [RFC 6578: Collection Synchronization for WebDAV, RFC Editor](https://www.rfc-editor.org/info/rfc6578/)
5. [RFC 6764: Locating Services for CalDAV and CardDAV, RFC Editor](https://www.rfc-editor.org/info/rfc6764/)
6. [RFC 4791 (PDF), greenbytes](https://greenbytes.de/tech/webdav/rfc4791.pdf)
7. [CalDAV vs the Nylas Calendar API, Nylas Docs](https://developer.nylas.com/docs/cookbook/calendar/caldav-vs-calendar-api/)
8. [CalDAV API Developer's Guide, Google for Developers](https://developers.google.cn/workspace/calendar/caldav/v2/guide?hl=en)
9. [RFC 7809: CalDAV Time Zones by Reference, RFC Editor](https://www.rfc-editor.org/info/rfc7809/)
10. [RFC 7953: Calendar Availability, RFC Editor](https://www.rfc-editor.org/info/rfc7953/)
11. [Calendaring Extensions (calext) Working Group charter, IETF Datatracker](https://datatracker.ietf.org/wg/calext/about/)
12. [icaldav DESIGN.md, allenporter on GitHub](https://github.com/allenporter/icaldav/blob/main/DESIGN.md)
13. [January 2005 CalConnect Interoperability Test Report](https://standards.calconnect.org/cc/cc-a0502-2005.html)

---
*Initially written Oct 15, 2026*

Topic: 物质世界与数学 › 测量与时间 › 历法 › Calendars as artifacts, products, and software › Calendar data standards and interoperability

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/caldav

English original: https://www.edgepedia.org/caldav
