Oxygen Chrome AlmaLinux Apache ve Nginx GZIP + Önbellek (Cache) Optimizasyon Rehberi - SONMEZZ

Konuyu Sesli Okuma

Manşet

En Yeniler
⏳ Manşetler yükleniyor...

Duyuru Alanı

Kutsal Bilgi
Kutsal Bilgi Tapınağı
Hoş Geldiniz Bilge Yolcu

Story

Yönetici
Admin
SVIP Member
Verified
Puanlar
5088
Başarılar
8
🚀 Apache & Nginx GZIP + Cache Optimizasyon Rehberi

Sunucu performansınızı artırın, sayfa yüklenme hızınızı güçlendirin ve doğru GZIP sıkıştırması ile tarayıcı önbellekleme ayarları sayesinde Google PageSpeed skorlarınızı yükseltin.

1️⃣ GZIP (Sıkıştırma)

GZIP, sunucudan ziyaretçinin tarayıcısına gönderilen dosyaların boyutunu azaltır. Bu, sayfa yüklenme hızını ciddi şekilde artırır ve bant genişliğinden tasarruf sağlar.


📁 Apache – /etc/httpd/conf.d/deflate.conf

<IfModule mod_deflate.c>

    # HTML, CSS, JS, XML ve font dosyalarını sıkıştır
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
    AddOutputFilterByType DEFLATE application/x-font
    AddOutputFilterByType DEFLATE application/x-font-opentype
    AddOutputFilterByType DEFLATE application/x-font-otf
    AddOutputFilterByType DEFLATE application/x-font-truetype
    AddOutputFilterByType DEFLATE application/x-font-ttf
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE font/opentype
    AddOutputFilterByType DEFLATE font/otf
    AddOutputFilterByType DEFLATE font/ttf
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE image/x-icon
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/xml

    # Eski tarayıcılar için düzeltme
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

    Header append Vary User-Agent

</IfModule>

📁 Nginx – /etc/nginx/conf.d/gzip.conf

gzip on;
gzip_disable "MSIE [1-6]\\.(?!.*SV1)";
gzip_proxied any;
gzip_comp_level 5;
gzip_types
    text/plain
    text/css
    application/javascript
    application/x-javascript
    text/xml
    application/xml
    application/rss+xml
    text/javascript
    image/x-icon
    image/bmp
    image/svg+xml;
gzip_vary on;

2️⃣ Cache (Tarayıcı Önbellekleme)

Tarayıcı önbellekleme, statik dosyaların (resimler, CSS, JS) kullanıcının cihazında belirli bir süre saklanmasını sağlar. Bu, tekrar ziyaretlerde sayfa yüklenme hızını büyük ölçüde artırır.


📁 Apache – /etc/httpd/conf.d/expires.conf

LoadModule expires_module modules/mod_expires.so

ExpiresActive On
ExpiresDefault "access plus 14 days"

ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType text/html "access plus 1 day"

📁 Nginx (sunucu bloğu içine)

location ~* \.(jpg|jpeg|gif|png|svg|ico|css|js|pdf|woff|woff2)$ {
    expires 30d;
    add_header Cache-Control "public, no-transform";
}

3️⃣ Servisleri Yeniden Başlat

Yapılandırma dosyalarını kaydettikten sonra Apache veya Nginx’i yeniden başlatmalısınız.


# Apache Yeniden Başlat
systemctl restart httpd

# Nginx Yeniden Başlat
systemctl restart nginx
✅ GZIP sıkıştırma ve önbellekleme artık sunucunuzda aktif!
Doğrulamak için şu araçları kullanabilirsiniz:
GZIP TestCache Test

Yanıtlamak için burayı tıklayın.
comment url
Giriş Yap