68 lines
2.3 KiB
ApacheConf
68 lines
2.3 KiB
ApacheConf
# Enable compression
|
|
<IfModule mod_deflate.c>
|
|
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json application/xml
|
|
</IfModule>
|
|
|
|
# Enable browser caching
|
|
<IfModule mod_expires.c>
|
|
ExpiresActive On
|
|
|
|
# Images
|
|
ExpiresByType image/jpeg "access plus 1 year"
|
|
ExpiresByType image/gif "access plus 1 year"
|
|
ExpiresByType image/png "access plus 1 year"
|
|
ExpiresByType image/webp "access plus 1 year"
|
|
ExpiresByType image/svg+xml "access plus 1 year"
|
|
ExpiresByType image/x-icon "access plus 1 year"
|
|
|
|
# CSS and JavaScript
|
|
ExpiresByType text/css "access plus 1 month"
|
|
ExpiresByType application/javascript "access plus 1 month"
|
|
ExpiresByType text/javascript "access plus 1 month"
|
|
|
|
# HTML
|
|
ExpiresByType text/html "access plus 1 hour"
|
|
|
|
# Fonts
|
|
ExpiresByType font/ttf "access plus 1 year"
|
|
ExpiresByType font/otf "access plus 1 year"
|
|
ExpiresByType font/woff "access plus 1 year"
|
|
ExpiresByType font/woff2 "access plus 1 year"
|
|
ExpiresByType application/font-woff "access plus 1 year"
|
|
</IfModule>
|
|
|
|
# Add Cache-Control headers
|
|
<IfModule mod_headers.c>
|
|
# 1 Year for images, fonts
|
|
<FilesMatch "\.(ico|pdf|jpg|jpeg|png|gif|webp|svg|js|css|ttf|otf|woff|woff2)$">
|
|
Header set Cache-Control "max-age=31536000, public"
|
|
</FilesMatch>
|
|
|
|
# 1 Month for CSS and JS
|
|
<FilesMatch "\.(css|js)$">
|
|
Header set Cache-Control "max-age=2592000, public"
|
|
</FilesMatch>
|
|
|
|
# 1 Hour for HTML
|
|
<FilesMatch "\.(html|htm)$">
|
|
Header set Cache-Control "max-age=3600, public"
|
|
</FilesMatch>
|
|
|
|
# Security headers
|
|
Header set X-Content-Type-Options "nosniff"
|
|
Header set X-Frame-Options "SAMEORIGIN"
|
|
Header set X-XSS-Protection "1; mode=block"
|
|
Header set Referrer-Policy "strict-origin-when-cross-origin"
|
|
</IfModule>
|
|
|
|
# Enable Gzip compression
|
|
<IfModule mod_gzip.c>
|
|
mod_gzip_on Yes
|
|
mod_gzip_dechunk Yes
|
|
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
|
|
mod_gzip_item_include handler ^cgi-script$
|
|
mod_gzip_item_include mime ^text/.*
|
|
mod_gzip_item_include mime ^application/x-javascript.*
|
|
mod_gzip_item_exclude mime ^image/.*
|
|
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
|
|
</IfModule> |