Apa MIME type untuk file .docx?
MIME type (media type) untuk file Microsoft Word dengan ekstensi .docx adalah application/vnd.openxmlformats-officedocument.wordprocessingml.document. Tipe ini merupakan arsip ZIP berisi file XML, sehingga sudah terkompresi. Server lama yang tidak mengenali tipe ini mungkin menyajikan file DOCX sebagai application/zip, sehingga browser menyimpannya sebagai .zip.
Header Content-Type
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document; charset=utf-8
Tipe berbasis teks sebaiknya menyertakan charset agar browser dapat men-decode karakter dengan benar.
Konfigurasi server
| Server | Konfigurasi |
|---|---|
Nginx (mime.types atau types {}) | application/vnd.openxmlformats-officedocument.wordprocessingml.document docx; |
Apache (.htaccess) | AddType application/vnd.openxmlformats-officedocument.wordprocessingml.document .docx |
IIS (web.config) | <mimeMap fileExtension=".docx" mimeType="application/vnd.openxmlformats-officedocument.wordprocessingml.document" /> |
| Node.js / Express | res.type('docx') atau res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document; charset=utf-8') |
| Amazon S3 | Atur Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document pada objek (metadata), atau berikan --content-type application/vnd.openxmlformats-officedocument.wordprocessingml.document ke aws s3 cp |
Apakah file .docx perlu dikompresi?
Tidak. File Microsoft Word sudah terkompresi secara internal, sehingga gzip atau Brotli hanya membuang CPU dan hampir tidak mengurangi ukuran — kadang malah membuatnya lebih besar. Jangan sertakan application/vnd.openxmlformats-officedocument.wordprocessingml.document dalam konfigurasi kompresi kamu.
Mengapa MIME type penting
Browser memutuskan apa yang dilakukan terhadap sebuah respons — ditampilkan, dijalankan, diputar, atau diunduh — berdasarkan header Content-Type, bukan ekstensi file. Dengan X-Content-Type-Options: nosniff, tipe yang salah menyebabkan stylesheet dan script diblokir sepenuhnya. Untuk unggahan, jangan pernah percaya tipe yang dikirim klien; periksa isi file (magic bytes-nya) di server.
Cari MIME type
Cari semua ekstensi file dan MIME type umum, lengkap dengan header Content-Type siap salin.
Pertanyaan yang sering diajukan
Apa MIME type untuk .docx?
application/vnd.openxmlformats-officedocument.wordprocessingml.document.Bagaimana cara mengatur Content-Type untuk .docx di Nginx?
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx; tercantum dalam blok types (biasanya di /etc/nginx/mime.types), lalu muat ulang Nginx.