Missing `Access-Control-Max-Age` Header in HTTP Responses Causes Performance Issues

Đang mở
#2,161 1 bình luận 2 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 11 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Lĩnh vực
api, performance

Hướng nghiên cứu

Issue này nhắm đến các phản hồi của HTTP API và các header CORS allow-* hiện có; trước tiên hãy xác định nơi các header đó được phát ra. Xác minh việc hoàn thành bằng cách xác nhận rằng các phản hồi có Access-Control-Max-Age: 86400 và kết quả preflight của trình duyệt có thể được lưu vào bộ nhớ đệm.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Description:

Version Information:

  • Version: 0.24.32
  • Commit SHA: a57ad4a2742c1cefb25d3288b33ed25c6570e0d2
  • Build Date: 2025-09-09

Problem:
The current HTTP API responses include the following headers for Cross-Origin Resource Sharing (CORS):

  • access-control-allow-headers: *
  • access-control-allow-methods: *
  • access-control-allow-origin: *

However, the Access-Control-Max-Age header is missing. This header is crucial for performance as it tells browsers how long they can cache the results of a CORS preflight request.

Without this header, the browser is forced to send a preflight OPTIONS request before every actual HTTP request to check if the CORS protocol is understood and the request is safe to send. This results in unnecessary, repetitive preflight requests, which significantly degrades the performance of front-end applications.

Suggestion:
It is recommended to add the Access-Control-Max-Age header to the HTTP responses. A suggested value is 86400 seconds (24 hours), which is the maximum value supported by Firefox.

Example:
Access-Control-Max-Age: 86400

Adding this header will allow browsers to cache the preflight response, eliminating the need for repeated OPTIONS requests and improving the overall performance and responsiveness of the front-end.

Image
Ngôn ngữ chính
C
Star
17.3k
Fork
562
Merge trung bình
10 ngày 15 giờ
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của tursodatabase/libsql

Tất cả issue của tursodatabase/libsql

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.