Skip to content

缓存

一句话解释

缓存是 temporary storage 那个 keeps 频繁地 accessed 数据所以它 能是 served faster 不使用 re-获取从 原始源.

用大白话说

Caching is the practice of storing copies of data in a fast-access location so future requests can be served faster. On the web, caching happens at multiple levels: browser cache, CDN cache, and server cache.

The browser cache stores downloaded resources (HTML, CSS, JS, images) so that on the next visit, they can be loaded from disk instead of re-downloading. HTTP headers control this: 缓存-Control sets caching directives (max-age, no-cache, no-store), and ETag/最后-修改 enable conditional requests.

Effective caching dramatically improves page load speed and reduces server load. The tradeoff is that cached content can become stale. Cache-busting techniques (versioned filenames, query parameters) ensure users get fresh content when it changes.

示例

http
Cache-Control: public, max-age=3600
ETag: "abc123"

// Browser caches for 1 hour (3600 seconds)
// Next request: If-None-Match: "abc123"
// Server: 304 Not Modified (use cache)

HTTP 缓存请求头: 缓存-Control 设置 lifetime, ETag 启用 efficient revalidation 使用 304 响应.

相关术语

相关资源

相关课程

解读错误信息

用大白话解释常见错误——什么意思、为什么发生、如何修复。

查看错误

← 返回术语表