# 静态网页

静态网页是存储在服务器上的一组 HTML、CSS 和 [JavaScript](https://www.edgepedia.org/zh/javascript) 文件，按存储原样发送给每一位访问者，不包含按请求或按用户改变内容的服务器端逻辑。对于任何给定的 URL，所有用户收到的内容都相同。<sup>[1](https://developer.mozilla.org/en-US/docs/Glossary/SSG)</sup>“静态”一词意为“按原样提供”：当浏览器请求该页面时，服务器在其存储中找到该文件并原封不动地发回。<sup>[2](https://developer.mozilla.org/en-US/docs/Learn_web_development/Howto/Web_mechanics/What_is_a_web_server)</sup>

| 关键事实 | 详情 |
|---|---|
| 构成 | 一组直接提供的 HTML、CSS 和 JavaScript 文件，不含服务器端代码或数据库<sup>[1](https://developer.mozilla.org/en-US/docs/Glossary/SSG)</sup> |
| 决定性行为 | 对于任何给定的 URL，所有用户收到相同内容；服务器只需处理 GET 请求，不根据 URL 参数或 cookie 改变响应<sup>[1](https://developer.mozilla.org/en-US/docs/Glossary/SSG)</sup><sup> • </sup><sup>[3](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Server-side/First_steps/Client-Server_overview)</sup> |
| 首个实例 | 第一个网页 http://info.cern.ch/hypertext/WWW/TheProject.html 运行在欧洲核子研究中心（CERN）的一台 NeXT 计算机上，是一个静态超文本文档<sup>[4](https://home.cern/science/computing/the-birth-of-the-web/short-history-web/)</sup> |
| 典型用途 | 博客、文档、个人网站和营销网站，以及其他由内容驱动、无需在服务器端获取或生成数据的网站<sup>[1](https://developer.mozilla.org/en-US/docs/Glossary/SSG)</sup><sup> • </sup><sup>[5](https://docs.aws.amazon.com/hands-on/latest/host-static-website/faq.html)</sup> |
| 托管 | 仍需要 Web 服务器或托管服务来提供其文件，但不需要服务器端应用处理；内容可从 CDN 或 Amazon S3 等对象存储提供，因而易于随流量扩展<sup>[5](https://docs.aws.amazon.com/hands-on/latest/host-static-website/faq.html)</sup><sup> • </sup><sup>[2](https://developer.mozilla.org/en-US/docs/Learn_web_development/Howto/Web_mechanics/What_is_a_web_server)</sup> |
| 性能 | 在一项服务器基准测试中，对静态资源的请求在 Nginx 上比动态资源快约 20 倍，在 Apache 上快约 10 倍<sup>[6](https://www.lunduniversity.lu.se/lup/publication/1982364)</sup> |
| 规模化生产 | 静态站点生成器将用 Markdown、reStructuredText、HTML 或 React 编写的内容提前编译为优化后的静态文件<sup>[1](https://developer.mozilla.org/en-US/docs/Glossary/SSG)</sup> |

## 服务机制

当浏览器请求一个页面时，它向 Web 服务器发送一个携带该文件 URL 的 HTTP 请求。HTTP 服务器检查所请求的 URL 是否匹配某个现有文件；若匹配，就将文件内容发回浏览器。若不匹配，服务器检查是否应为此请求动态生成文件；若两者皆不可行，则返回错误消息，最常见的是 `404 Not Found`。<sup>[2](https://developer.mozilla.org/en-US/docs/Learn_web_development/Howto/Web_mechanics/What_is_a_web_server)</sup>

对于静态站点，只有第一个分支有意义。服务器存储网站的文件，即 HTML 文档及其相关资源，包括图像、CSS 样式表、JavaScript 文件、字体和视频，并将它们按原样提供。<sup>[2](https://developer.mozilla.org/en-US/docs/Learn_web_development/Howto/Web_mechanics/What_is_a_web_server)</sup>由于服务器不存储可修改的数据，它只需处理 GET 请求，其响应也不会因 URL 参数或 cookie 等 HTTP 请求数据而改变。<sup>[3](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Server-side/First_steps/Client-Server_overview)</sup>

## 静态页面与动态页面

区别在于 HTML 从何而来。纯 HTML 文件存储在服务器上并原样发送给客户端，因此被称为静态。当 Python 脚本或 ASP.NET 页面在服务器上运行时，其生成的 HTML 会根据接收到的数据而变化，从而使输出成为动态。例如，天气预报页面可以根据天气、用户位置和用户偏好显示不同的数据。<sup>[7](https://developer.mozilla.org/en-US/docs/Learn_web_development/Getting_started/Web_standards/The_web_standards_model)</sup>

两种方式在实践中相互交叠。服务器端语言通常在模板文件中定义 HTML 结构，这些模板大部分是静态 HTML，带有特殊的动态部分，随需要插入的数据而变化。<sup>[7](https://developer.mozilla.org/en-US/docs/Learn_web_development/Getting_started/Web_standards/The_web_standards_model)</sup>动态站点处理对 CSS、JavaScript 和静态图像等静态文件的请求时，方式与静态站点完全相同。<sup>[3](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Server-side/First_steps/Client-Server_overview)</sup>

这一选择有实际后果。静态网站最适合内容不常更新的情况；一旦内容需要频繁更新、个性化或动态生成，动态架构就更合适。<sup>[8](https://docs.aws.amazon.com/whitepapers/latest/build-static-websites-aws/build-static-websites-aws.html)</sup>一个根据访问者偏好由服务器端代码显示比分的体育新闻网站，是静态品牌微站点或内网信息页面的标准反例。<sup>[8](https://docs.aws.amazon.com/whitepapers/latest/build-static-websites-aws/build-static-websites-aws.html)</sup>

## 起源：最早的静态页面

[万维网](https://www.edgepedia.org/zh/world-wide-web)最初是完全静态的媒介。欧洲核子研究中心的英国研究员[蒂姆·伯纳斯-李](https://www.edgepedia.org/zh/tim-berners-lee)（Tim Berners-Lee）从 1989 年 3 月起提交了后来成为万维网的提案，到 1990 年圣诞节时，他已实现了 HTML、HTTP 和 URL，以及第一个 Web 服务器、浏览器和编辑器。<sup>[9](https://www.computerhistory.org/timeline/networking-the-web/)</sup><sup> • </sup><sup>[10](https://home.cern/world-wide-web-35/)</sup>第一个网站和 Web 服务器运行在欧洲核子研究中心一台地址为 info.cern.ch 的 NeXT 计算机上，第一个网页 http://info.cern.ch/hypertext/WWW/TheProject.html 包含指向万维网项目本身相关信息的链接，包括超文本的说明和创建 Web 服务器的技术细节。<sup>[4](https://home.cern/science/computing/the-birth-of-the-web/short-history-web/)</sup>早期页面还链接了对欧洲核子研究中心科学家有用的信息，例如欧洲核子研究中心电话簿和使用实验室中央计算机的指南；由于早年没有搜索引擎，搜索功能依赖关键词。<sup>[4](https://home.cern/science/computing/the-birth-of-the-web/short-history-web/)</sup>

1991 年 8 月 6 日，万维网向欧洲核子研究中心之外开放，实验室以外的人首次可以将其作为公共互联网服务访问。<sup>[11](https://time.com/21039/tim-berners-lee-web-proposal-at-25/)</sup>欧洲以外的第一台 Web 服务器于 1991 年 12 月在加利福尼亚的斯坦福直线加速器中心（SLAC）上线，由物理学家保罗·昆兹（Paul Kunz）与路易丝·阿迪斯（Louise Addis）和特里·洪（Terry Hung）安装，以便人们便捷地访问 SLAC 图书馆的 SPIRES 高能物理预印本数据库；安装于 1991 年 12 月 12 日完成。<sup>[12](https://ahro.slac.stanford.edu/wwwslac-exhibit)</sup>1993 年 4 月 30 日欧洲核子研究中心将 Web 软件放入公有领域后，增长十分迅速：NSF 骨干网上的 Web 流量占比在 1993 年 3 月测得为 0.1%，到 1993 年 9 月达到 1%；1993 年 10 月约有 200 台 Web 服务器，到 1994 年 6 月已有 1500 台。<sup>[13](https://home.cern/cern-celebrates-web-anniversary/)</sup><sup> • </sup><sup>[14](https://www.inf.usi.ch/faculty/jazayeri/theses/kerer.pdf)</sup>

## 托管与分发

托管静态网站仍需要 Web 服务器或托管服务来提供其文件，但不需要服务器端应用处理。<sup>[2](https://developer.mozilla.org/en-US/docs/Learn_web_development/Howto/Web_mechanics/What_is_a_web_server)</sup>内容可存储在内容分发网络（CDN）——一个由缓存服务器组成的分布式系统——中，从而易于随用户流量增长而扩展。<sup>[5](https://docs.aws.amazon.com/hands-on/latest/host-static-website/faq.html)</sup>[对象存储](https://www.edgepedia.org/zh/object-storage)服务的工作方式相同：要在 [Amazon S3](https://www.edgepedia.org/zh/amazon-s3) 上托管静态网站，需配置一个用于网站托管的存储桶，上传内容，并设置索引文档和可选的错误文档。<sup>[15](https://docs.aws.amazon.com/AmazonS3/latest/userguide/EnableWebsiteHosting.html)</sup>

CDN 分发也改变了缓存模式。例如在 Cloudflare Pages 上，每个已部署的资产会一直缓存在 CDN 上，直到下一次部署，静态资产自动从平台的分层缓存提供。<sup>[16](https://developers.cloudflare.com/pages/configuration/serving-pages/)</sup>在 Cloudflare 的定价方案中，对静态资产的请求在免费和付费层级均免费且不限量。<sup>[17](https://2abdbd9f.previews.developers.cloudflare.com/pages/functions/pricing/)</sup>

## 静态站点生成器

手工编写每个页面无法规模化，因此现代静态站点大多由静态站点生成器（SSG）生成，这种软件将源内容编译为成品的静态网站。作者用生成器接受的任何形式写作，如 Markdown、reStructuredText、HTML，有时是 React，生成器再将材料编译为一组浏览器可渲染的优化静态文件。<sup>[1](https://developer.mozilla.org/en-US/docs/Glossary/SSG)</sup>

与传统 Web 应用栈的决定性区别在于时机。静态站点生成器不在页面被请求时才按需生成视图，而是在构建时提前为站点的所有可能视图完成工作，因此视图可以提前准备好，随时供访问。一种想象方式是：一个脚本接收数据、内容和模板，处理它们，并输出一个装满结果页面和资产的文件夹。<sup>[18](https://www.netlify.com/blog/2020/04/14/what-is-a-static-site-generator-and-3-ways-to-find-the-best-one/)</sup>这类似于传统架构常在动态基础设施之上添加的缓存层，只不过缓存就是整个站点。<sup>[18](https://www.netlify.com/blog/2020/04/14/what-is-a-static-site-generator-and-3-ways-to-find-the-best-one/)</sup>

静态站点在博客、文档和其他无需在服务器端获取或生成数据的内容驱动型网站中仍然常见。它们快速、安全且更易部署，因为它们可以从 CDN 提供。<sup>[1](https://developer.mozilla.org/en-US/docs/Glossary/SSG)</sup>

## 性能与安全

提供预构建文件在机制上比按请求生成文件更简单，测量结果也反映了这一点。[隆德大学](https://www.edgepedia.org/zh/lund-university)（Lund University）对两种 Web 服务器的可扩展性研究发现，请求静态资源在 Nginx 上比动态资源快约 20 倍，在 Apache 上快约 10 倍。<sup>[6](https://www.lunduniversity.lu.se/lup/publication/1982364)</sup>提供静态页面的 Web 服务器性能已得到充分研究和理解，相比之下，动态页面分发历来获得的解析和实证研究要少得多。<sup>[19](https://web.cs.wpi.edu/~claypool/papers/cgi-perf/)</sup>

安全优势源于架构。静态站点由提前构建的 HTML、CSS 和 JavaScript 文件组成，直接从 CDN 或基础 Web 服务器提供，没有可供攻击者针对的服务器端应用代码或数据库。<sup>[20](https://sitegrade.io/en/blog/static-vs-dynamic-security/)</sup>从业者也报告了同样的经验：爱达荷大学图书馆（University of Idaho Library）在一个未使用、未打补丁的 [WordPress](https://www.edgepedia.org/zh/wordpress) 实例通过插件被攻破、向页面注入广告之后转向静态方案，并发现静态服务器消除了重大安全风险，同时降低了基础设施、预算和人员方面的障碍。<sup>[21](https://onlineacademiccommunity.uvic.ca/dhsi/wp-content/uploads/sites/7317/2023/07/C24_Coursepack-DHSI-2023-Creating-Digital-Collections.pdf)</sup>

## 从静态网页到动态网页，再回归

万维网自身的历史与其起点方向相反。万维网最初只有静态 HTML 页面；动态网页的诞生一般被定在 1993 年 CGI（[通用网关接口](https://www.edgepedia.org/zh/common-gateway-interface)）的引入，它使服务器端处理和动态内容成为可能。<sup>[22](https://ptacts.uspto.gov/ptacts/public-informations/petitions/1479134/download-documents?artifactId=ShMB-494MwrBy3fMgvURokbwlwZ4WrwkoQ2dGVkfpNc1GgKuLcASvLY)</sup>此后数年，万维网从静态内容分发媒介转变为交互式动态媒介。<sup>[23](https://www.sciencedirect.com/science/article/abs/pii/S0140366402002219)</sup>

近年来，钟摆部分回摆。一类“消失的”Web 框架通过提供早期 Web 和简单静态站点的优点，质疑了前几代框架的假设。<sup>[24](https://arxiv.org/abs/2304.01947)</sup>以 HTML 为先的 Web 开发方法同样强调尽可能直接使用 HTML，带有一种源自 Web 早期的极简主义。<sup>[25](https://arxiv.org/abs/2602.17193)</sup>这种模式并非回到 1991 年：用 React 和 Angular 等 JavaScript 框架构建的现代静态站点可以提供传统上只有 PHP 和 ASP.NET 等服务器端语言才能实现的丰富应用体验。<sup>[5](https://docs.aws.amazon.com/hands-on/latest/host-static-website/faq.html)</sup>

## References

1. [Static site generator (SSG), MDN Web Docs Glossary](https://developer.mozilla.org/en-US/docs/Glossary/SSG)
2. [What is a web server?, MDN Learn Web Development](https://developer.mozilla.org/en-US/docs/Learn_web_development/Howto/Web_mechanics/What_is_a_web_server)
3. [Client-server overview, MDN Learn Web Development](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Server-side/First_steps/Client-Server_overview)
4. [A short history of the Web, CERN](https://home.cern/science/computing/the-birth-of-the-web/short-history-web/)
5. [Frequently Asked Questions, Host a Static Website, AWS](https://docs.aws.amazon.com/hands-on/latest/host-static-website/faq.html)
6. [Implementering av prestandatest för att undersöka skalbarheten utav två webbservrar, Lund University](https://www.lunduniversity.lu.se/lup/publication/1982364)
7. [The web standards model, MDN Learn Web Development](https://developer.mozilla.org/en-US/docs/Learn_web_development/Getting_started/Web_standards/The_web_standards_model)
8. [Hosting Static Websites on AWS, AWS Whitepaper](https://docs.aws.amazon.com/whitepapers/latest/build-static-websites-aws/build-static-websites-aws.html)
9. [Networking & The Web, Timeline of Computer History, Computer History Museum](https://www.computerhistory.org/timeline/networking-the-web/)
10. [World Wide Web at 35, CERN](https://home.cern/world-wide-web-35/)
11. [The Web at 25: Revisiting Tim Berners-Lee's Amazing Proposal, Time](https://time.com/21039/tim-berners-lee-web-proposal-at-25/)
12. [WWW@SLAC Exhibit, SLAC Archives, History & Records Office](https://ahro.slac.stanford.edu/wwwslac-exhibit)
13. [CERN celebrates Web anniversary, CERN](https://home.cern/cern-celebrates-web-anniversary/)
14. [A Short History of Web Evolution (Kerer thesis, Università della Svizzera italiana)](https://www.inf.usi.ch/faculty/jazayeri/theses/kerer.pdf)
15. [Enabling website hosting, Amazon Simple Storage Service User Guide](https://docs.aws.amazon.com/AmazonS3/latest/userguide/EnableWebsiteHosting.html)
16. [Serving Pages, Cloudflare Pages docs](https://developers.cloudflare.com/pages/configuration/serving-pages/)
17. [Pricing, Cloudflare Pages docs](https://2abdbd9f.previews.developers.cloudflare.com/pages/functions/pricing/)
18. [What is a Static Site Generator?, Netlify blog](https://www.netlify.com/blog/2020/04/14/what-is-a-static-site-generator-and-3-ways-to-find-the-best-one/)
19. [The performance of Web servers delivering static pages (Claypool et al., WPI)](https://web.cs.wpi.edu/~claypool/papers/cgi-perf/)
20. [Static vs Dynamic Security Comparison, SiteGrade](https://sitegrade.io/en/blog/static-vs-dynamic-security/)
21. [Benefits and Challenges of the Static Approach, University of Idaho Library / DHSI 2023 coursepack](https://onlineacademiccommunity.uvic.ca/dhsi/wp-content/uploads/sites/7317/2023/07/C24_Coursepack-DHSI-2023-Creating-Digital-Collections.pdf)
22. [A history of the dynamic web, Pingdom](https://ptacts.uspto.gov/ptacts/public-informations/petitions/1479134/download-documents?artifactId=ShMB-494MwrBy3fMgvURokbwlwZ4WrwkoQ2dGVkfpNc1GgKuLcASvLY)
23. [Performance comparison of dynamic web platforms, ScienceDirect](https://www.sciencedirect.com/science/article/abs/pii/S0140366402002219)
24. [The Rise of Disappearing Frameworks in Web Development, arXiv](https://arxiv.org/abs/2304.01947)
25. [The Case for HTML First Web Development, arXiv](https://arxiv.org/abs/2602.17193)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/static-web-page

English original: https://www.edgepedia.org/static-web-page
