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 Windows 11 ISO Download Blocked and Error Messages
  • How to Make Your Website Vibrate with Web Haptics
  • Measuring LLM Bullshit Benchmark
  • A Step-by-Step Guide to ZITADEL Identity Infrastructure
  • How NVIDIA G-SYNC Pulsar is Finally Fixing Motion Blur Forever
  • How Multipathing Keeps Your Linux Systems Running Smoothly!
  • Forgejo: A Self-hosted Github Alternative You Should Try
  • Introducing Zo Computer, How it Will Changing Personal Data Science Forever
  • Which AI Brain Should Your Coding Agent Use? A Deep Dive into the OpenHands Index
  • Hoppscotch, The Postman Killer: Why You Should Switch from Postman to Hoppscotch Right Now
  • Nitrux 6.0 Released with Linux Kernel 6.19: What’s New?
  • How to Upgrade Pop!_OS 22.04 LTS to 24.04 LTS: A Step-by-Step Guide
  • KDE Plasma 6.6.2 Released: Key Bug Fixes and Enhancements Explained
  • Meet the Huawei NetEngine 8000: The Router Powering the Next Generation of AI-Driven Networks!
  • LLM Settings That Every AI Developer Must Know
  • Is Your Second Monitor a Mess? Kubuntu 26.04 Resolute Raccoon Finally Fixes Multi-Display Woes!
  • How to Run Massive AI Models on Your Mac: Unlocking Your Hidden VRAM Secrets
  • How to Create Gemini CLI Agent Skills
  • WTF? Ubuntu Planning Mandatory Age Verification
  • Why This Retro PC is Actually a Modern Beast: Maingear Retro98
  •  Windows 11 Taskbar Update: How to Move and Resize Your Taskbar Again
  • Does KDE Plasma Require Systemd? Debunking the Mandatory Dependency Myths
  •  How to Fix ‘docs.google.com Refused to Connect’ Error in Windows 10/11
  • Aerynos Feb 2026 Update: Faster Desktops and Moss Performance Boost
  • Pangolin 1.16 Adds SSH Auth Daemon: What You Need to Know
  • Inilah 10 Kesalahan Fatal Saat Beli Properti yang Bisa Bikin Kalian Bangkrut!
  • Belum Tahu Cara Masuk Simpatika Terbaru? Ini Cara Login PTK EMIS GTK IMP 2026 Supaya Cek TPG Jadi Lebih Gampang!
  • Inilah Cara Bikin Konten Animasi AI Cuma Modal HP Supaya Bisa Gajian Rutin dari YouTube
  • Inilah Alasan Kenapa Zakat ke Ormas yang Belum Diakui Negara Nggak Bisa Dipakai Buat Ngurangin Pajak!
  • Inilah Cara Belanja di Indomaret Pakai Shopee PayLater yang Praktis dan Bikin Hemat!
  • The Secret Reason Seedance 2.0 is Realistic
  • Exploring Microsoft Phi-4 Reasoning Vision 15B
  • Gemini 3.1 Flash-Lite Released: How to Master Google’s Fastest AI Model for Real-World Projects
  • Qwen Is Ruined! Why the Masterminds Behind Qwen 3.5 Left Alibaba Cloud
  • GPT-5.3 Instant Revealed: How the New OpenAI Update Changes Everything for AI Users
  • 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