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 build a high-performance private photo cloud with Immich and TrueNAS SCALE
  • How to Build an Endgame Local AI Agent Setup Using an 8-Node NVIDIA Cluster with 1TB Memory
  • How to Master Windows Event Logs to Level Up Your Cybersecurity Investigations and SOC Career
  • How to Build Ultra-Resilient Databases with Amazon Aurora Global Database and RDS Proxy for Maximum Uptime and Performance
  • How to Build Real-Time Personalization Systems Using AWS Agentic AI to Make Every User Feel Special
  • How to Transform Your Windows 11 Interface into a Sleek and Modern Aesthetic Masterpiece
  • How to Understand Google’s New TPU 8 Series for Massive AI Training and Inference
  • How to Level Up Your PC Gaming Experience with the New Valve Steam Controller and Its Advanced Features
  • Is it Time to Replace Nano? Discover Fresh, the Terminal Text Editor You Actually Want to Use
  • How to Design a Services Like Google Ads
  • How to Fix 0x800ccc0b Outlook Error: Step-by-Step Guide for Beginners
  • How to Fix NVIDIA App Error on Windows 11: Simple Guide
  • 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
  • Apa itu Jabatan Panitera Muda Mahkamah Agung, Berapa Gaji & Tunjangannya 2026?
  • Inilah Kenapa Bisa Ada Sensasi Mencekam di Bangunan Tua
  • Apa itu Pengertian Frontier Market di Dunia Saham?
  • Apa itu Krnl Executor Roblox Mei 2026?
  • Inilah Cara Entry Nilai Rapor SPMBJ Jatim 2026 dan Berkas yang Dipersiapkan
  • How to Automate Your Entire SEO Strategy Using a Swarm of 100 Free AI Agents Working in Parallel
  • How to create professional presentations easily using NotebookLM’s AI power for school projects and beyond
  • How to Master SEO Automation with Google Gemini 3.1 Flash-Lite in Google AI Studio
  • How to create viral AI video ads and complete brand assets using the Claude and Higgsfield MCP integration
  • How to Transform Your Mac Into a Supercharged AI Assistant with Perplexity Personal Computer
  • 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