Last active
April 18, 2018 04:32
-
-
Save yesasha/79c601e8ea520e3f3a494df6f7ef7805 to your computer and use it in GitHub Desktop.
Extension to Apache Server Configs for the case when mod_expires.c is not available. Also it does not depend on mod_mime.c since relies only on file extensions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MIT License | |
# Copyright (c) 2018 Aleksandr Yefremov | |
# Extension to Apache Server Configs v3.0.0 | |
# https://github.com/h5bp/server-configs-apache | |
# For the case when mod_expires.c is not available | |
# Also it does not depend on mod_mime.c since relies only on file extension. | |
<IfModule !mod_expires.c> | |
<IfModule mod_headers.c> | |
Header set Cache-Control "max-age=2592000" | |
# CSS | |
<FilesMatch "\.css$"> | |
Header set Cache-Control "max-age=31536000" | |
</FilesMatch> | |
# Data interchange | |
<FilesMatch "\.(atom|rss)$"> | |
Header set Cache-Control "max-age=3600" | |
</FilesMatch> | |
<FilesMatch "\.(ics|json|map|topojson|jsonld|geojson|rdf|xml)$"> | |
Header set Cache-Control "max-age=0" | |
</FilesMatch> | |
# Favicon (cannot be renamed!) and cursor images | |
<FilesMatch "\.(cur|ico)$"> | |
Header set Cache-Control "max-age=604800" | |
</FilesMatch> | |
# HTML | |
<FilesMatch "\.(html|htm)$"> | |
Header set Cache-Control "max-age=0" | |
</FilesMatch> | |
# JavaScript | |
<FilesMatch "\.(js|mjs)$"> | |
Header set Cache-Control "max-age=31536000" | |
</FilesMatch> | |
# Manifest files | |
<FilesMatch "\.webmanifest$"> | |
Header set Cache-Control "max-age=604800" | |
</FilesMatch> | |
<FilesMatch "\.(webapp|appcache)$"> | |
Header set Cache-Control "max-age=0" | |
</FilesMatch> | |
# WebAssembly | |
<FilesMatch "\.wasm$"> | |
Header set Cache-Control "max-age=31536000" | |
</FilesMatch> | |
# Markdown | |
<FilesMatch "\.(markdown|md)$"> | |
Header set Cache-Control "max-age=0" | |
</FilesMatch> | |
# Media files | |
<FilesMatch "\.(pdf|swf|oga|ogg|opus|mp3|bmp|gif|jpeg|jpg|png|svg|svgz|webp|f4v|f4p|m4v|mp4|ogv|webm)$"> | |
Header set Cache-Control "max-age=2592000" | |
</FilesMatch> | |
# Web fonts | |
# Collection | |
<FilesMatch "\.ttc$"> | |
Header set Cache-Control "max-age=2592000" | |
</FilesMatch> | |
# Embedded OpenType (EOT) | |
<FilesMatch "\.eot$"> | |
Header set Cache-Control "max-age=2592000" | |
</FilesMatch> | |
# OpenType | |
<FilesMatch "\.otf$"> | |
Header set Cache-Control "max-age=2592000" | |
</FilesMatch> | |
# TrueType | |
<FilesMatch "\.ttf$"> | |
Header set Cache-Control "max-age=2592000" | |
</FilesMatch> | |
# Web Open Font Format (WOFF) 1.0 | |
<FilesMatch "\.woff$"> | |
Header set Cache-Control "max-age=2592000" | |
</FilesMatch> | |
# Web Open Font Format (WOFF) 1.0 | |
<FilesMatch "\.woff2$"> | |
Header set Cache-Control "max-age=2592000" | |
</FilesMatch> | |
</IfModule> | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment