perf: move caching headers to apache virtualhost config for guaranteed delivery

This commit is contained in:
mstfyldz
2026-05-04 23:59:24 +03:00
parent 4ea472fcc9
commit d1bf2829cf

View File

@@ -1,17 +1,35 @@
FROM php:8.2-apache FROM php:8.2-apache
# Apache modüllerini aktif et # Modülleri aktif et
RUN a2enmod rewrite expires deflate headers RUN a2enmod rewrite expires deflate headers
# .htaccess dosyalarının çalışması için AllowOverride izni ver # Apache Site Konfigürasyonunu doğrudan güncelle (Header ve Önbellek zorlaması)
RUN sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf RUN echo '<VirtualHost *:80>\n\
DocumentRoot /var/www/html\n\
<Directory /var/www/html>\n\
AllowOverride All\n\
Require all granted\n\
</Directory>\n\
# Gzip ve Cache ayarları\n\
<IfModule mod_expires.c>\n\
ExpiresActive On\n\
ExpiresDefault "access plus 1 month"\n\
ExpiresByType image/jpg "access plus 1 year"\n\
ExpiresByType image/jpeg "access plus 1 year"\n\
ExpiresByType image/png "access plus 1 year"\n\
ExpiresByType image/webp "access plus 1 year"\n\
ExpiresByType font/woff2 "access plus 1 year"\n\
ExpiresByType text/css "access plus 1 month"\n\
ExpiresByType application/javascript "access plus 1 month"\n\
</IfModule>\n\
<IfModule mod_headers.c>\n\
Header set Cache-Control "max-age=31536000, public"\n\
</IfModule>\n\
</VirtualHost>' > /etc/apache2/sites-available/000-default.conf
# Proje dosyalarını kopyala # Proje dosyalarını kopyala
COPY . /var/www/html/ COPY . /var/www/html/
# İzinleri ayarla
RUN chown -R www-data:www-data /var/www/html/ RUN chown -R www-data:www-data /var/www/html/
WORKDIR /var/www/html WORKDIR /var/www/html
EXPOSE 80 EXPOSE 80