PerformanceServerTiming: thuộc tính name

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2023.

Note: This feature is available in Web Workers.

Thuộc tính chỉ đọc name trả về giá trị chuỗi của tên số liệu do máy chủ chỉ định.

Giá trị

Một chuỗi.

Ví dụ

Ghi lại các mục nhập thời gian máy chủ

Các số liệu thời gian máy chủ yêu cầu máy chủ gửi tiêu đề Server-Timing. Ví dụ:

http
Server-Timing: cache;desc="Cache Read";dur=23.2
js
const observer = new PerformanceObserver((list) => {
  list.getEntries().forEach((entry) => {
    entry.serverTiming.forEach((serverEntry) => {
      console.log(
        `${serverEntry.name} (${serverEntry.description}) duration: ${serverEntry.duration}`,
      );
      // Logs "cache (Cache Read) duration: 23.2"
    });
  });
});

["navigation", "resource"].forEach((type) =>
  observer.observe({ type, buffered: true }),
);

Thông số kỹ thuật

Thông số kỹ thuật
Server Timing
# dom-performanceservertiming-name

Tương thích trình duyệt

Xem thêm