Kiểu MIME của file .webmanifest là gì?
Kiểu MIME (media type) của file Web app manifest có phần mở rộng .webmanifest là application/manifest+json. Manifest PWA được liên kết bằng <link rel="manifest">. Trình duyệt cũng chấp nhận application/json.
Header Content-Type
Content-Type: application/manifest+json
Các kiểu dựa trên văn bản nên có charset để trình duyệt giải mã ký tự đúng cách.
Cấu hình máy chủ
| Máy chủ | Cấu hình |
|---|---|
Nginx (mime.types hoặc types {}) | application/manifest+json webmanifest; |
Apache (.htaccess) | AddType application/manifest+json .webmanifest |
IIS (web.config) | <mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" /> |
| Node.js / Express | res.type('webmanifest') hoặc res.setHeader('Content-Type', 'application/manifest+json') |
| Amazon S3 | Đặt Content-Type: application/manifest+json cho đối tượng (metadata), hoặc truyền --content-type application/manifest+json vào aws s3 cp |
File .webmanifest có nên được nén không?
Có. Web app manifest là văn bản, nên bật gzip hoặc Brotli cho application/manifest+json thường giúp giảm 50–80 % dung lượng truyền tải. Hãy đảm bảo danh sách nén của máy chủ có kiểu này — kiểm tra bằng công cụ kiểm tra nén website.
Vì sao kiểu MIME quan trọng
Trình duyệt quyết định sẽ làm gì với một phản hồi — hiển thị, thực thi, phát hay tải xuống — dựa trên header Content-Type, chứ không dựa trên phần mở rộng file. Với X-Content-Type-Options: nosniff, kiểu sai khiến stylesheet và script bị chặn hoàn toàn. Với upload, đừng bao giờ tin kiểu do client gửi lên; hãy kiểm tra nội dung file (magic bytes) trên server.
Tra cứu kiểu MIME
Tìm kiếm mọi phần mở rộng file và kiểu MIME phổ biến, kèm header Content-Type sẵn sàng sao chép.
Câu hỏi thường gặp
Kiểu MIME của .webmanifest là gì?
application/manifest+json.Làm sao để đặt Content-Type cho .webmanifest trong Nginx?
application/manifest+json webmanifest; có trong khối types (thường nằm ở /etc/nginx/mime.types) rồi tải lại Nginx.