Skip to main content

.htaccess Media Types and Character Encodings

.htaccess Media Types and Character Encodings

Apache uses mod_mime to assign content metadata to the content selected for an HTTP response by mapping patterns in the URI or filenames to the metadata values.


Changing the metadata for a file does not change the value of the Last-Modified header. Thus, previously cached copies may still be used by a client or proxy, with the previous headers.

If you change the metadata (language, content type, character set, or encoding) you may need to 'touch' affected files (updating their last modified date) to ensure that all visitors receive the corrected content headers.


Serve resources with the proper media types (MIME types)

Associates media types with one or more extensions to make sure the resources will be served appropriately.


Servers should use text/javascript for JavaScript resources!


<IfModule mod_expires.c>

# Data interchange
AddType application/atom+xml atom
AddType application/json json map topojson
AddType application/ld+json jsonld
AddType application/rss+xml rss
AddType application/geo+json geojson
AddType application/rdf+xml rdf
AddType application/xml xml

# JavaScript
AddType text/javascript js mjs

# Manifest files
AddType application/manifest+json webmanifest
AddType application/x-web-app-manifest+json webapp
AddType text/cache-manifest appcache

# Media files
AddType audio/mp4 f4a f4b m4a
AddType audio/ogg oga ogg opus
AddType image/bmp bmp
AddType image/svg+xml svg svgz
AddType image/webp webp
AddType video/mp4 f4v f4p m4v mp4
AddType video/ogg ogv
AddType video/webm webm
AddType image/x-icon cur ico

# HEIF Images
AddType image/heic heic
AddType image/heif heif

# HEIF Image Sequence
AddType image/heics heics
AddType image/heifs heifs

# AVIF Images
AddType image/avif avif

# AVIF Image Sequence
AddType image/avis avis

# WebAssembly
AddType application/wasm wasm

# Web fonts
AddType font/woff woff
AddType font/woff2 woff2
AddType application/ eot
AddType font/ttf ttf
AddType font/collection ttc
AddType font/otf otf

# Other
AddType application/octet-stream safariextz
AddType application/x-bb-appworld bbaw
AddType application/x-chrome-extension crx
AddType application/x-opera-extension oex
AddType application/x-xpinstall xpi
AddType text/calendar ics
AddType text/markdown markdown md
AddType text/vcard vcard vcf
AddType text/vnd.rim.location.xloc xloc
AddType text/vtt vtt
AddType text/x-component htc