Skip to content
Tutorial emka
Menu
  • Home
  • Debian Linux
  • Ubuntu Linux
  • Red Hat Linux
Menu

Cara Tuning mod_expires pada Apache demi Server Cache yang Efisien

Posted on January 31, 2024

 

Modul mod_expires pada Apache digunakan untuk mengontrol pengaturan header Expires HTTP dan direktif max-age pada header Cache-Control dalam respons server. Header-header ini menentukan seberapa lama klien (browser atau proxy) akan menyimpan sumber daya dalam cache. Mengoptimalkan pengaturan ini dapat secara signifikan mengurangi beban server dan meningkatkan pengalaman pengguna dengan mengurangi waktu pemuatan.

Berikut adalah bagian mod_expires yang dioptimalkan untuk server produksi, mencakup berbagai jenis file:

## EXPIRES CACHING ##
<ifmodule mod_expires.c="">
    ExpiresActive On

    # Default expiration: 1 hour after request
    ExpiresDefault "now plus 1 hour"

    # HTML components
    ExpiresByType text/html "access plus 0 seconds"

    # Data interchange
    ExpiresByType application/json "access plus 0 seconds"
    ExpiresByType application/xml "access plus 0 seconds"
    ExpiresByType application/rss+xml "access plus 1 hour"
    ExpiresByType application/atom+xml "access plus 1 hour"

    # Favicon (can be cached for a long time)
    ExpiresByType image/x-icon "access plus 1 year"

    # Media: images, video, audio
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/webp "access plus 1 month"
    ExpiresByType video/ogg "access plus 1 month"
    ExpiresByType audio/ogg "access plus 1 month"
    ExpiresByType video/mp4 "access plus 1 month"
    ExpiresByType video/webm "access plus 1 month"

    # CSS and JavaScript
    ExpiresByType text/css "access plus 1 year"
    ExpiresByType application/javascript "access plus 1 year"
    ExpiresByType application/x-javascript "access plus 1 year"
    ExpiresByType text/javascript "access plus 1 year"

    # Webfonts
    ExpiresByType font/otf "access plus 1 month"
    ExpiresByType font/ttf "access plus 1 month"
    ExpiresByType font/woff "access plus 1 month"
    ExpiresByType font/woff2 "access plus 1 month"
    ExpiresByType application/font-woff "access plus 1 month"
    ExpiresByType application/font-woff2 "access plus 1 month"
    ExpiresByType image/svg+xml "access plus 1 month"

    # Other
    ExpiresByType application/pdf "access plus 1 month"
    ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
</ifmodule>

Penjelasan Pengaturan

  • ExpiresDefault: Waktu penyimpanan default untuk sumber daya yang tidak cocok dengan aturan lain. Diatur menjadi 1 jam, tetapi dapat disesuaikan berdasarkan seberapa sering konten Anda berubah.
  • HTML dan Data Interchange: Jenis konten ini biasanya sering berubah dan diatur untuk kedaluwarsa segera (0 detik) atau setelah periode singkat (1 jam untuk feed).
  • Favicons: Jarang berubah dan dapat disimpan dalam cache untuk periode yang lebih lama (1 tahun).
  • Media Files: Gambar, video, dan audio biasanya tidak diperbarui dengan frekuensi tinggi. Diatur untuk kedaluwarsa dalam 1 bulan, tetapi dapat ditingkatkan jika sumber daya ini jarang berubah.
  • CSS dan JavaScript: Karena file-file ini mungkin berubah dengan pembaruan situs web, tetapi tidak sefrekuensi konten HTML, mereka diatur untuk periode cache yang lebih lama (1 tahun). Pastikan versi file ini diatur untuk menghindari masalah cache saat diperbarui.
  • Webfonts: Font umumnya tidak berubah setelah diatur, jadi periode cache yang lebih lama (1 bulan) adalah sesuai.
  • Tipe Lainnya: Untuk sumber daya seperti PDF dan jenis gambar tertentu, sesuaikan waktu penyimpanan berdasarkan seberapa sering sumber daya ini diperbarui.

Catatan Tambahan

Sesuaikan pengaturan ini berdasarkan frekuensi pembaruan konten spesifik Anda.

Pastikan Anda memiliki strategi versioning untuk aset seperti CSS dan JavaScript untuk mencegah masalah cache ketika file-file ini diperbarui.

Ingatlah bahwa caching yang agresif mungkin menyebabkan masalah ketika konten diperbarui di server tetapi masih di-cache di browser klien.

Monitor secara teratur dan sesuaikan pengaturan ini berdasarkan kebutuhan spesifik dan umpan balik dari lingkungan produksi.

Recent Posts

  • How to Fix Excel Formula Errors: Quick Fixes for #NAME
  • How to Clear Copilot Memory in Windows 11 Step by Step
  • How to Show Battery Percentage on Windows 11
  • How to Fix VMSp Service Failed to Start on Windows 10/11
  • How to Fix Taskbar Icon Order in Windows 11/10
  • How to Disable Personalized Ads in Copilot on Windows 11
  • What is the Microsoft Teams Error “We Couldn’t Connect the Call” Error?
  • Why Does the VirtualBox System Service Terminate Unexpectedly? Here is the Full Definition
  • Why is Your Laptop Touchpad Overheating? Here are the Causes and Fixes
  • How to Disable All AI Features in Chrome Using Windows 11 Registry
  • How to Avoid Problematic Windows Updates: A Guide to System Stability
  • What is Microsoft Visual C++ Redistributable and How to Fix Common Errors?
  • What is the 99% Deletion Bug? Understanding and Fixing Windows 11 File Errors
  • How to Add a Password to WhatsApp for Extra Security
  • How to Recover Lost Windows Passwords with a Decryptor Tool
  • How to Fix Python Not Working in VS Code Terminal: A Troubleshooting Guide
  • Game File Verification Stuck at 0% or 99%: What is it and How to Fix the Progress Bar?
  • Why Does PowerPoint Underline Hyperlinks? Here is How to Remove Them
  • AI Bug Hunting with Semgrep
  • What is the Excel Power Query 0xc000026f Error?
  • How to Build Your Own Homelab AI Supercomputer 2026
  • How to Enable SSH in Oracle VirtualBox for Beginners
  • How to Intercept Secret IoT Camera Traffic
  • Build Ultra-Fast and Tiny Desktop Apps with Electrobun: A Beginner’s Guide
  • The Ultimate 2026 Coding Roadmap: How to Master Software Engineering with AI Agents
  • Inilah Rahasia ReciMe, Potensi Sukses dari Aplikasi Resep Sederhana
  • Perkuat Kemandirian Industri Alat Kesehatan Nasional, Astra Komponen Indonesia Hadirkan Alat Kesehatan Berbasis Teknologi Digital
  • Vidrush, Solusi Produksi Video massal buat Channel Faceless
  • Inilah Higgsfield AI Audio, Trik Canggih Buat Voice Cloning dan Dubbing Video Youtube Otomatis!
  • Everything You Need to Know About Project X and the Rumored AI-Powered Remaster of The Sims 4
  • How to Use Orbax Checkpointing with Keras and JAX for Robust Training
  • How to Automate Any PDF Form Using the Power of Manus AI
  • How to Training Your Own YOLO26 Object Detection Model!
  • How to Build a Full-Stack Mobile App in Minutes with YouWare AI
  • How to Create Consistent Characters and Cinematic AI Video Production with Seedance
  • Apa itu Spear-Phishing via npm? Ini Pengertian dan Cara Kerjanya yang Makin Licin
  • Apa Itu Predator Spyware? Ini Pengertian dan Kontroversi Penghapusan Sanksinya
  • Mengenal Apa itu TONESHELL: Backdoor Berbahaya dari Kelompok Mustang Panda
  • Siapa itu Kelompok Hacker Silver Fox?
  • Apa itu CVE-2025-52691 SmarterMail? Celah Keamanan Paling Berbahaya Tahun 2025
©2026 Tutorial emka | Design: Newspaperly WordPress Theme