perf: replace .htaccess with nginx.conf for Coolify/Nginx environment
This commit is contained in:
60
.htaccess
60
.htaccess
@@ -1,60 +0,0 @@
|
|||||||
# Enable GZIP Compression
|
|
||||||
<IfModule mod_deflate.c>
|
|
||||||
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
|
|
||||||
AddOutputFilterByType DEFLATE application/javascript application/x-javascript application/json
|
|
||||||
AddOutputFilterByType DEFLATE application/xml application/xhtml+xml
|
|
||||||
AddOutputFilterByType DEFLATE image/svg+xml
|
|
||||||
AddOutputFilterByType DEFLATE font/woff font/woff2 application/font-woff application/font-woff2
|
|
||||||
</IfModule>
|
|
||||||
|
|
||||||
# Browser Caching - Static Assets
|
|
||||||
<IfModule mod_expires.c>
|
|
||||||
ExpiresActive On
|
|
||||||
|
|
||||||
# Images (1 year)
|
|
||||||
ExpiresByType image/jpeg "access plus 1 year"
|
|
||||||
ExpiresByType image/png "access plus 1 year"
|
|
||||||
ExpiresByType image/gif "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"
|
|
||||||
|
|
||||||
# Fonts (1 year)
|
|
||||||
ExpiresByType font/woff "access plus 1 year"
|
|
||||||
ExpiresByType font/woff2 "access plus 1 year"
|
|
||||||
ExpiresByType application/font-woff "access plus 1 year"
|
|
||||||
ExpiresByType application/font-woff2 "access plus 1 year"
|
|
||||||
ExpiresByType font/ttf "access plus 1 year"
|
|
||||||
ExpiresByType font/otf "access plus 1 year"
|
|
||||||
|
|
||||||
# CSS & JavaScript (1 month)
|
|
||||||
ExpiresByType text/css "access plus 1 month"
|
|
||||||
ExpiresByType application/javascript "access plus 1 month"
|
|
||||||
ExpiresByType text/javascript "access plus 1 month"
|
|
||||||
|
|
||||||
# HTML (1 hour)
|
|
||||||
ExpiresByType text/html "access plus 1 hour"
|
|
||||||
</IfModule>
|
|
||||||
|
|
||||||
# Cache-Control Headers
|
|
||||||
<IfModule mod_headers.c>
|
|
||||||
# CSS & JS - 1 month
|
|
||||||
<FilesMatch "\.(css|js)$">
|
|
||||||
Header set Cache-Control "public, max-age=2592000, immutable"
|
|
||||||
</FilesMatch>
|
|
||||||
|
|
||||||
# Images - 1 year
|
|
||||||
<FilesMatch "\.(jpg|jpeg|png|gif|webp|svg|ico)$">
|
|
||||||
Header set Cache-Control "public, max-age=31536000, immutable"
|
|
||||||
</FilesMatch>
|
|
||||||
|
|
||||||
# Fonts - 1 year
|
|
||||||
<FilesMatch "\.(woff|woff2|ttf|otf|eot)$">
|
|
||||||
Header set Cache-Control "public, max-age=31536000, immutable"
|
|
||||||
</FilesMatch>
|
|
||||||
|
|
||||||
# HTML - no-cache (always check for updates)
|
|
||||||
<FilesMatch "\.(html|htm)$">
|
|
||||||
Header set Cache-Control "public, max-age=3600, must-revalidate"
|
|
||||||
</FilesMatch>
|
|
||||||
</IfModule>
|
|
||||||
43
nginx.conf
Normal file
43
nginx.conf
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
# GZIP Compression
|
||||||
|
gzip on;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_proxied any;
|
||||||
|
gzip_comp_level 6;
|
||||||
|
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml font/woff2;
|
||||||
|
|
||||||
|
# Browser Caching
|
||||||
|
location ~* \.(jpg|jpeg|png|gif|webp|svg|ico|cur|gz|svgz|mp4|ogg|ogv|webm|htc)$ {
|
||||||
|
expires 1y;
|
||||||
|
access_log off;
|
||||||
|
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~* \.(css|js)$ {
|
||||||
|
expires 1M;
|
||||||
|
access_log off;
|
||||||
|
add_header Cache-Control "public, max-age=2592000, immutable";
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~* \.(woff|woff2|ttf|otf|eot)$ {
|
||||||
|
expires 1y;
|
||||||
|
access_log off;
|
||||||
|
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||||
|
}
|
||||||
|
|
||||||
|
# HTML - No cache
|
||||||
|
location ~* \.(html|htm)$ {
|
||||||
|
expires 1h;
|
||||||
|
add_header Cache-Control "public, max-age=3600, must-revalidate";
|
||||||
|
}
|
||||||
|
|
||||||
|
error_page 404 /404.html;
|
||||||
|
location = /404.html {
|
||||||
|
internal;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user