资源 · 06

安全、高性能的网络:以用户旅程为导向的审计指南

围绕用户真正需要完成的操作,审计速度、可访问性、安全性和转化率。

已更新 · 16 min

从走廊透过深色玻璃看到的虚构无人网络验证室,配有抽象浏览器窗口显示屏、网络机柜及酒红色文件夹 由人工智能生成的编辑插图

本指南有助于实现的目标

  • 优先处理真正的用户障碍。
  • 减少网站重量、依赖项和攻击面。
  • 将性能与转化率关联起来。
  • 在真实条件下验证修复。

快速检查

  • 是否已命名三个最有价值的用户旅程?
  • 是否已针对移动设备对字段数据进行分段?
  • 网站是否支持键盘操作?
  • 每个第三方脚本是否都有所有者?
  • 表单错误是否有助于用户完成操作?

分步指南

  1. 1

    选择关键旅程

    根据业务价值选择搜索、阅读、联系、注册、购买或管理等旅程。 描述设备、网络、环境和预期结果。

    交付成果:优先级排序的测试场景。

  2. 2

    测量现场和实验室环境。

    将汇总的真实用户数据与可复现的测试相结合。 观察加载速度、响应速度、稳定性、错误和放弃率,而不将分析简化为单一分数。

    交付成果:分段基线。

  3. 3

    检查关键路径。

    审查初始 HTML、字体、图像、JavaScript、缓存、服务器响应和阻塞资源。 为服务于用户旅程的各个元素分配明确的预算。

    交付成果:性能预算。

  4. 4

    减少暴露面。

    清点第三方脚本、依赖项、标头、Cookie、会话、表单和管理界面。 移除不必要的组件并加强服务器端安全。

    交付成果:依赖项和保护注册表。

  5. 5

    测试包容性体验。

    通过键盘、屏幕阅读器、小屏幕、缩放和错误状态运行所有操作。 检查标签、焦点、对比度和恢复消息。

    交付成果:可访问性和摩擦报告。

  6. 6

    带防护措施的发布

    自动化稳定控制,观察发布后的业务成果并准备回滚。 当实际业务流程得到改善且无倒退时,修复程序即可关闭。

    交付成果:持续验证计划。

理解、计算与判断

Core Web Vitals:理解p75与测量边界

LCP描述主要内容的加载,INP描述交互响应,CLS描述视觉稳定性。使用第75百分位,并区分移动设备与桌面设备。工具仅对输入值进行分类,不会访问或测量您的网站。

记录URL或页面组、日期范围、设备和测量工具。实验室测试可用于复现原因,但不能替代真实访问的分布。缺少INP值不代表交互响应是瞬时的。

指标与证据

指标含义所需证据
LCP ≤ 2.5秒 加载处于良好区间 p75、主要元素及其加载延迟
INP ≤ 200毫秒 响应处于良好区间 p75与复现的慢交互
CLS ≤ 0.1 稳定性处于良好区间 p75与发生位移的元素

计算规则

良好:LCP ≤ 2.5;INP ≤ 200;CLS ≤ 0.1。差:LCP > 4;INP > 500;CLS > 0.25。两者之间为需要改进。

虚构示例

示例情境

预订页面在实验室中似乎运行迅速,但其确认按钮在移动设备上的响应速度却很慢。 团队按设备和用户旅程细分现场测量,然后减少对 JavaScript 和键盘行为的测试。

决策及预期证据

只有当任务仍然可访问、交互得到改善且用户旅程的安全控制仍然有效时,才能接受更改。

管理指标

指标衡量内容首要行动
旅程成功率用户顺利完成操作,无阻塞错误首先修复多个环节共享的故障
现场性能真实设备上的加载、交互和稳定性在解决主要瓶颈之前先处理部分环节
第三方成本字节数、主线程时间和不受直接控制的请求移除、延迟或替换每个非必要的第三方
错误率按步骤划分的技术和输入故障改进预防、消息和恢复机制

常见错误

  • 仅优化首页
  • 将实验室评分与实际体验混淆
  • 添加安全工具却未消除不必要的风险
  • 为了节省毫秒而损害可访问性或测量功能

常见问题解答

性能和安全性是否存在冲突?

否。减少依赖项、JavaScript 和不必要的请求通常可以改善两者。 应根据实际用户旅程和风险来衡量权衡取舍。

我们应该以多少分为目标?

单一阈值无法取代现场数据。 应按用户旅程、设备和受众设定预算,然后跟踪预算与业务成果。

为什么要在审核中包含可访问性?

因为无法通过键盘操作、无法理解或无法恢复的快速操作,对用户和企业而言都是失败。

参考资料:数据、用途与局限

文档核查日期 .

此语言版本的详细参考说明以英语提供。

参考资料:数据、用途与局限
来源与目的已核实的数据或指标使用方法需要保留的局限
MDN · Cookie boundaries

Understand session-cookie scope and SameSite boundaries.

Secure, HttpOnly, SameSite and the __Host- prefix address different risks. A site can include multiple origins. Test external navigation, subdomains, provider returns and authenticated operations separately.

深入了解方法 →

Cookie configuration does not replace CSRF checks or server-side authorisation.

IANA 参考与 DNSSEC 解读

此语言版本的详细参考说明以英语提供。

Distinguish resolution, caching and web responses

An outage can occur before any HTTP response. Examine DNS resolution, its validation and caches separately from the web server.

  • Record the failing stage and the resolver involved.
  • A received TTL and RRSIG expiration are different constraints.
  • An error disappearing on one device does not prove recovery for all visitors.

Read the registries and try the cache model →

IETF · RFC 4033 · §3–5 · 2026-10-23

扩展:权限与访问

此语言版本的详细参考说明以英语提供。

Include the browser in exposure scope

A hardened site can still be visited from a profile with highly authorised extensions. Keep the boundary between site security, browser capabilities and managed-endpoint choices visible.

  • Inventory the test profile’s extensions with version and accountable owner.
  • Explain each required host and check optional permissions actually granted.
  • Test restriction and removal; static manifest reading cannot replace code and traffic observation.

Read the permission directory and manifest examples →

Microsoft Learn · Manage Microsoft Edge extensions using group policies · Enterprise policy documentation consulted 2026-10-23

CSP:指令、回退与流程

此语言版本的详细参考说明以英语提供。

CSP tells a browser which resources and certain behaviours a page permits. Reviewing it requires distinguishing the requested directive, its possible fallback, policy mode and delivery. A directive name in a header alone does not establish that a user journey is protected.

Twelve fallback chains extracted from CSP3 §6.8.3, three independent checks and eight fictional scenarios. Reference: W3C Working Draft of 16 September 2026, a work in progress rather than a final Recommendation. The consulted IANA registry contains sixteen names and was updated 3 February 2023.

W3C · Content Security Policy Level 3 · Mike West, Antonio Sartori · Working Draft · 2026-09-16 · work in progress · §2.2.1, §3, §6.8.3–6.8.4, §8.1

Twelve fallback orders and three checks without default-src

The selected list is not added to default-src. A present but empty directive also stops lookup. The final three rows are not fetch chains: base-uri, form-action and frame-ancestors require their own directive.

Twelve fallback orders and three checks without default-src
Requested checkLookup order · first present directive winsReference
script-src-elemscript-src-elem → script-src → default-srcCSP3 §6.8.3
script-src-attrscript-src-attr → script-src → default-srcCSP3 §6.8.3
style-src-elemstyle-src-elem → style-src → default-srcCSP3 §6.8.3
style-src-attrstyle-src-attr → style-src → default-srcCSP3 §6.8.3
worker-srcworker-src → child-src → script-src → default-srcCSP3 §6.8.3
connect-srcconnect-src → default-srcCSP3 §6.8.3
manifest-srcmanifest-src → default-srcCSP3 §6.8.3
object-srcobject-src → default-srcCSP3 §6.8.3
frame-srcframe-src → child-src → default-srcCSP3 §6.8.3
media-srcmedia-src → default-srcCSP3 §6.8.3
font-srcfont-src → default-srcCSP3 §6.8.3
img-srcimg-src → default-srcCSP3 §6.8.3
base-uribase-uribase-uri
form-actionform-actionform-action
frame-ancestorsframe-ancestorsframe-ancestors

CSP阅读练习

Choose a case and a check. This workshop uses pre-separated example directives, keeps the first occurrence of each name and stops at the first directive present in the stated order. It does not parse arbitrary CSP or check source expressions, URLs, nonces, hashes, redirects or actual browser behaviour.

Each policy is read separately with its mode and delivery. Values are displayed as text; the workshop loads no resource named by an example.

Delivery and mode: three different readings

Delivery and mode: three different readings
MechanismWhat to checkLimit
Content-Security-PolicyResponse header and policies actually received.Each enforced policy adds its constraint; a second cannot relax the first.
Content-Security-Policy-Report-OnlyViolation observation and the configured reporting path.Monitoring mode does not enforce this policy’s blocking.
meta http-equivElement position and content processed before it.Report-Only, frame-ancestors, report-uri and sandbox are not supplied by this mechanism.

Eight reading scenarios and acceptance exercises

C01 · Fallback to default-src

script-src-elem

1 · enforce · header

Content-Security-Policy: default-src 'none'

Reading : script-src-elem and script-src are absent, so the chain reaches default-src. This list does not define base-uri, form-action or frame-ancestors.

Test to add : Select those three independent checks as well. Do not infer protection against embedding the page from default-src.

C02 · Fallback is not source-list merging

script-src-attr

1 · enforce · header

Content-Security-Policy: default-src 'none'; script-src 'self'

Reading : script-src-attr reaches script-src before default-src. Their lists are not concatenated. The presence of self alone does not authorise an inline event handler.

Test to add : Test script elements, event attributes and other relevant mechanisms separately. The workshop selects a directive; it does not decide whether a script executes.

C03 · A worker reaches child-src before script-src

worker-src

1 · enforce · header

Content-Security-Policy: default-src 'none'; script-src 'self'; child-src https://frames.example.net

Reading : worker-src is absent. The first directive present in its fallback order is child-src. The word child does not mean only iframes are affected.

Test to add : Check workers and frames separately; record the selected control and observe the browser in its real context.

C04 · A specific directive stops fallback

worker-src

1 · enforce · header

Content-Security-Policy: default-src 'none'; child-src https://frames.example.net; worker-src 'self' blob:

Reading : worker-src is present: neither child-src nor default-src supplies the list for this check. Its value is displayed without checking a URL, redirect or local scheme.

Test to add : Test creation and loading of expected workers together with their own policy and dependencies. Do not treat this illustrative list as universal configuration.

C05 · An empty directive is not absent

img-src

1 · enforce · header

Content-Security-Policy: img-src; img-src https://images.example.net; default-src 'self'

Reading : The first img-src occurrence is retained with an empty list. The second occurrence is discarded in this policy; the workshop does not replace the first with default-src.

Test to add : Check duplicates in configuration and the received response. A present field without source expressions must not be treated as missing.

C06 · Two enforced policies remain two constraints

connect-src

1 · enforce · header

Content-Security-Policy: default-src 'self'; connect-src 'none'

2 · enforce · header

Content-Security-Policy: connect-src https://api.example.net

Reading : The first policy retains connect-src none; the second names an origin. Adding the second does not lift the first policy’s restriction. Results are shown separately.

Test to add : Observe every received header after CDN and proxy handling. Do not unite both policies’ sources into a broader allowlist.

C07 · Monitoring is not enforcement

script-src-elem

1 · enforce · header

Content-Security-Policy: script-src 'self'

2 · report-only · header

Content-Security-Policy-Report-Only: script-src 'none'

Reading : script-src is selected in both policies. The second is Report-Only: it monitors violations without enforcing its blocking. The first retains its own effect.

Test to add : Plan report collection and check real journeys before a separately decided enforcement change. A monitored directive name alone does not establish blocking.

C08 · frame-ancestors in meta is ignored

frame-ancestors

1 · enforce · meta

<meta http-equiv="Content-Security-Policy" content="default-src 'none'; frame-ancestors 'none'">

Reading : This directive is not supported in a meta-delivered policy. default-src remains a resource control rather than a fallback for frame-ancestors.

Test to add : Inspect the policy actually received in headers and authorised embeddings. A meta element cannot supply Report-Only mode either.

Sixteen IANA names: registration differs from support

CSP2 registry references are preserved verbatim. This copy does not list every CSP3 addition: absence of worker-src or script-src-elem does not invalidate those names in CSP3. Conversely, a historical name such as plugin-types does not establish support in a current browser.

IANA · Content Security Policy Directives · Registry updated 2023-02-03 · consulted 2026-10-23

Sixteen IANA names: registration differs from support
Registered nameRegistry referenceRegistration date
base-urihttps://www.w3.org/TR/CSP2/2015-11-24
child-srchttps://www.w3.org/TR/CSP2/2015-11-24
connect-srchttps://www.w3.org/TR/CSP2/2015-11-24
default-srchttps://www.w3.org/TR/CSP2/2015-11-24
font-srchttps://www.w3.org/TR/CSP2/2015-11-24
form-actionhttps://www.w3.org/TR/CSP2/2015-11-24
frame-ancestorshttps://www.w3.org/TR/CSP2/2015-11-24
frame-srchttps://www.w3.org/TR/CSP2/2015-11-24
img-srchttps://www.w3.org/TR/CSP2/2015-11-24
media-srchttps://www.w3.org/TR/CSP2/2015-11-24
object-srchttps://www.w3.org/TR/CSP2/2015-11-24
plugin-typeshttps://www.w3.org/TR/CSP2/2015-11-24
report-urihttps://www.w3.org/TR/CSP2/2015-11-24
sandboxhttps://www.w3.org/TR/CSP2/2015-11-24
script-srchttps://www.w3.org/TR/CSP2/2015-11-24
style-srchttps://www.w3.org/TR/CSP2/2015-11-24

IANA · Protocol Registries · CC0 1.0 · Revised 2021-11-10

Test protection without breaking the journey

Test protection without breaking the journey
Proposed CIE journeyControl to reviewUseful evidence
Sign-in and recoveryRequired scripts, styles, frames and connections.Success, useful refusal, recovery and errors observed with received policies.
Payment or external integrationframe-src for embedded content; frame-ancestors for who embeds your page.Test the two directions separately rather than conflate them.
Form and confirmationform-action, validation scripts and API requests.Submission and confirmation received; a click alone does not establish processing.
Worker and deferred featuresworker-src and its fallback order.Creation, dependent resources and visible errors in the authorised context.
Third-party additionInventory of actually required scripts, connections, images and frames.Documented need and sampled journeys; no wildcard added to hide a breakage.
Progressive releaseObserved mode, configuration version and stop criteria.Reviewed reports, attributed defects, tests and an enforcement decision.

Associate a policy with the page version and test critical journeys after CDN or proxy transformations. CSP is defence in depth: it does not replace output encoding, dependency control or access checks. This model explains directive selection rather than a security verdict.

Provenance, edition and licence

W3C CSP3 · Working Draft 2026-09-16 · reviewed 2026-10-23 · IANA registry 2023-02-03

IANA XML SHA-256: 42d2068b345f9b1df2bb124dd8b20e26d16dbd86960aafb62624aa285f2997c0

W3C HTML SHA-256: df90a9028632b39c70d9ed40dadfadbc2f3f690621ecf6212ef4f1376005738e

W3C · Software and Document license · 2023 · Effective 2023-01-01 · full notice below

This document and its lookup data include material derived from Content Security Policy Level 3, https://www.w3.org/TR/2026/WD-CSP3-20260916/. Copyright © 2026 World Wide Web Consortium. https://www.w3.org/copyright/software-license-2023/
Changes: selected fallback lists extracted as data; original CIE explanations, fictional scenarios and limited lookup implementation added.

This work is being provided by the copyright holders under the following license.
By obtaining and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
Permission to copy, modify, and distribute this work, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the work or portions thereof, including modifications:
The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C software and document short notice should be included.
Notice of any changes or modifications, through a copyright statement on the new code or document such as "This software or document includes material copied from or derived from [title and URI of the W3C document]. Copyright © [$year-of-document] World Wide Web Consortium. https://www.w3.org/copyright/software-license-2023/"
THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT.
The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the work without specific, written prior permission. Title to copyright in this work will at all times remain with copyright holders.

Core Web Vitals:阈值和实测数据

此语言版本的详细参考说明以英语提供。

Web performance: state the measurement scope

Before announcing a gain, retain device, URL or origin and collection period.

  • Compare the same device, scope and documented periods.
  • Do not turn missing data into zero.
  • Verify functions and accessibility after the fix.

Read the thresholds and try the p75 reader →

Google · About PageSpeed Insights · Living documentation · consulted 2026-10-23

官方参考文献

参考文献支持该方法。 请根据您的实际情况调整检查;它们并非认证。 原始参考文献标题和源文档可能使用其他语言。

参考资料查阅日期 .