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

  • Linux News Roundup February 2026
  • How to Install JellyFin Media Server on Samsung TV with TizenOS
  • Why OneNote Clears Your Notes
  • AMD NPU Monitoring on Linux: A Beginner’s Guide to AI Chip Tracking!
  • How to Fix AMD Adrenalin’s Game Detection Issues on Windows
  • Greg Kroah-Hartman Wins Multiple Award at European Open Source Awards!
  • What are Microsoft Copilot Reminders?
  • What’s New in Plasma 6.7? Quick Notification History Clear-Up!
  • Awesome Alternatives to Microsoft Defender Application Guard (MDAG)
  • How tto Enable DLSS 4 & 5 for Your GPU
  • Backlinks: Why They’re Super Important for Your Website!
  • Gnome’s Smart Windows: Tiling Shell 17.3 Makes Organizing Your Screen Easier!
  • How to Replace Notepad with Microsoft Edit
  • What’s New in Shotcut 26.1?
  • Spotify Introduces Group Chat Feature: Sharing Music and Podcasts with Friends Directly
  • Microsoft Will Fix Windows 11 Performance and User Experience Issues in 2026
  • Windows 11 KB5074105 Update Explained
  • Windows 11 Start Menu Resize Issues Explained
  • Definitely Not Fried Chicken Game Explained
  • What is Windows 11 Cross Device Resume?
  • Google Chrome Gemini Integration Explained
  • Microsoft Launches Maia 200: The New 3nm AI Accelerator Outperforming Google and Amazon
  • How to Secure Your Moltbot (ClawdBot): Security Hardening Fixes for Beginners
  • Workflows++: Open-source Tool to Automate Coding
  • MiroThinker-v1.5-30B Model Explained: Smart AI That Actually Thinks Before It Speaks
  • Apa itu Apple iPhone Lipat ‘Clamshell’?
  • ToonMe, Cara Ubah Foto Jadi Kartun Disney Gemoy
  • Apa itu Apple CarPlay Ultra?
  • Steam Wallet Pending Setelah Jual Barang? Ini Dia Penyebab & Cara Mengatasinya!
  • Apakah Lowongan PT Rifan Financindo Asli atau Modus Penipuan?
  • Cara Membuat Podcast dari PDF dengan NotebookLlama dan Groq
  • Tutorial Membuat Sistem Automatic Content Recognition (ACR) untuk Deteksi Logo
  • Apa itu Google Code Wiki?
  • Cara Membuat Agen AI Otomatis untuk Laporan ESG dengan Python dan LangChain
  • Cara Membuat Pipeline RAG dengan Framework AutoRAG
  • 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